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("확인","등록이 완료됐습니다.")
'PowerBuilder > Tip!' 카테고리의 다른 글
string 변환 (0) | 2018.01.09 |
---|---|
[파워빌더]DB에 저장된 이미지 다운로드 하기 (0) | 2017.10.17 |
DataWindow에서 중북 코드 체크 (0) | 2017.04.21 |
윈도우 open 이벤트에 작성하는 초기화 관련 (0) | 2015.09.16 |
DataWindow에 엑셀자료 UpLoad 하기 (0) | 2014.12.26 |