[ 파일 업로드 ]
blob blob_temp, blob_tot
integer li_filenum, li_index, li_loop
String ls_file, ls_filename
long ll_filelen, ll_read
String ls_yymm
Long ll_cnt, ll_rtn
pointer oldpointer // Declares a pointer variable
ls_yymm = String(dw_1.object.yymm[1], 'yyyymm')
if isnull(ls_yymm) or trim(ls_yymm) = '' then
messagebox("알림", "UPLOAD 대상 년월을 입력하세요")
return 1
end if
oldpointer = SetPointer(HourGlass!)
select count(*)
into :ll_cnt
from tb_sw23485
where comp_cd = :gs_company
and yymm = :ls_yymm ;
if ll_cnt > 0 then
ll_rtn = MessageBox("선택","기존 데이타를 삭제 하시겠습니까?", Question!, YesNo!, 1)
if ll_rtn = 1 then
delete from tb_table
where comp_cd = :gs_company
and yymm = :ls_yymm ;
messagebox("확인", "기존데이타 삭제 완료!!파일을 업로드 하세요!!!")
else
return 1
end if
end if
if GetFileOpenName("XLSX,XLS,DOC File",ls_file,ls_filename, "XLSX","XLSX Files, *.XLSX, XLS Files, *.XLS, DOC Files, *.DOC") = 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, blob_temp)
blob_tot = blob_tot + blob_temp
next
fileclose(li_filenum)
insert into tb_table(comp_cd, yymm, filename, filedata, create_id, create_dt, create_ip) values (:gs_company, :ls_yymm, :ls_filename, '', :gs_log_id, sysdate, :gs_ip_add);
updateblob tb_table set filedata = :blob_tot where comp_cd = :gs_company and yymm = :ls_yymm ;
if sqlca.sqlcode = 0 then
messagebox("알림", "첨부파일이 정상적으로 등록 되었습니다. "+ sqlca.sqlerrtext)
commit ;
else
messagebox("알림","첨부파일 등록에 오류가 발생하였습니다. " + sqlca.sqlerrtext)
rollback ;
end if
end if
end if
SetPointer(oldpointer)