Updating contents of blob
Symptom
Customer extracted some PDFs (stored in a blob on a table pdfs) to
a folder. The file names of the PDFs are the image sequence numbers of
his pdfs entries. After modifying these PDFs he wishes to update his
blob fields in the pdfs table.
Environment
-
Operating System: Any supported Windows version
-
PowerBuilder: Any supported version
Solution
The following steps will provide you with the desired
functionality:
-
Place an invisible ListBox (lb_pdfs)on your window
(w_pfds). -
Add the following PowerScript to a command button or function
that will provide the desired functionality:123456789101112131415161718192021222324252627282930integer li_fnum, li_rtnblob pdfblobString ls_pdfdir = "<your PDF root directory>"String ls_pdfNames[], ls_pdfkeys[]//Get a list of PDF files and associated keysw_pdfs.lb_pdfs.DirList("*.PDF", 16400, ls_pdfdir)li_pdffiles = w_pdfs.lb_pdfs.TotalItems()FOR li_pdffile = 1 TO li_pdffilesls_pdfname[li_pdffile] = w_pdfs.lb_pdfs.Item[li_pdffile]ls_pdfkey[li_pdffile] = Left(ls_pdfname[li_pdffile], Len(ls_pdfkey[li_pdffile]) - 4)NEXT// Update PDF database entriesFOR li_pdffile = 1 TO li_pdffiles// Open PDF fileli_fnum = FileOpen(ls_pdfdir + "/" + ls_pdfname[li_pdffile], StreamMode!)// Read PDF fileFileReadEx(li_fnum, pdfblob)// Update PDF entry in databaseUPDATEBLOB pdfs SET pdfdata = :pdfblob WHERE pdfkey = ls_pdfkey[li_pdffile] USING SQLCA;IF SQLCA.SQLNRows> 0 THENCOMMIT USING SQLCA ;END IFNEXT -
The pdf entries in the pdfs table are now updated with the
current PDF contents.
Document get from Powerbuilder help
Thank you for watching.
Subscribe
Login
0 Comments
Oldest