본문 바로가기

PowerBuilder/Tip!

[파워빌더] 이미지 DB에 저장하기

blob lb_temp, lb_tot

integer li_filenum, li_index, li_loop

String ls_file, ls_filename, ls_emp_cd, ls_path

long ll_filelen, ll_read, ll_rowcnt, i, ll_cnt



if GetFileOpenName("JPG,BMP File",ls_file,ls_filename,"JPG","JPG Files, *.JPG,BMP Files, *.BMP") = 1 then

ll_filelen = FileLength(ls_file)

li_filenum = FileOpen(ls_file,StreamMode!,Read!,LockRead!)

 

if li_filenum <> -1 then

if ll_filelen > 32765 then

if mod(ll_filelen,32765) = 0 then

li_loop = ll_filelen / 32765

else

li_loop = (ll_filelen/32765) + 1

end if

else  

li_loop = 1

end if

for li_index = 1 to li_loop

fileRead(li_filenum,lb_temp)

lb_tot = lb_tot + lb_temp

next

 

fileclose(li_filenum)

//중복 체크

select

count(*)

into 

:ll_cnt

from

table명

where

empno = :ls_emp_cd

using sqlca;

if sqlca.sqlcode = -1 then

rollback using sqlca;

messagebox("select",SQLCA.SQLErrText)

return

end if

if ll_cnt = 0 then

insert into table명

(

empno, 

empnp_pic) 

values 

(

:ls_emp_cd, 

null)

using sqlca;

if sqlca.sqlcode = -1 then

rollback using sqlca;

messagebox("insert1",SQLCA.SQLErrText)

return

end if

updateblob 

table명 

set 

empnp_pic = :lb_tot 

where 

empno = :ls_emp_cd

using sqlca;


if sqlca.sqlcode = -1 then

rollback using sqlca;

messagebox("update1",SQLCA.SQLErrText)

return

end if

else

updateblob 

table명 

set 

empnp_pic = :lb_tot 

where 

empno = :ls_emp_cd

using sqlca;


if sqlca.sqlcode = -1 then

rollback using sqlca;

messagebox("update2",SQLCA.SQLErrText)

return

end if

end if

end if

end if


commit using sqlca;

messagebox("확인","등록이 완료됐습니다.")