Is it possible to send big string over 32k from powerbuilder to PL/SQL(Oracle) stored procedure? If yes, Please let us know how to do that?
Is it possible to send big string over 32k from powerbuilder to PL/SQL(Oracle) stored procedure? If yes, Please let us know how to do that?
You accomplish this by breaking your strings into 32K chunks of data.
Here's a previous response on this topic from Chris:
I have had to do that in my Imaging Apps for Passport Canada. What I did was create a temporary DB table with a blob column but use a auto-incremented sequence number as part of the image's primary key on the TEMP table. Then, using the basic FileRead() method syntax read 32K "chunks" of the blob data at a time & store that into the TEMP table's blob column with an UpdateBlob command on each FileRead loop cycle. At the end of the TEMP Blob table load (aka the end of the FileRead loop), I called a DBMS Stored Procedure passing the image's primary key of the TEMP table to the SP. In the SP, I would loop through the TEMP table blob data & reconstruct the entire Blob data in the SP's work area. From there, the SP would load the fully reconstructed image into the proper Blob table & delete the TEMP table blob rows. That gets around using all that client machine local storage that can affect the App user.
You could also keep the image "chunked" in the DBMS & read the image back to the client using a SelectBlob command loop using the Blob Table's image sequence number to keep the binary chunks arranged properly. Then use the basic file FileWrite command syntax to write it to the client's PC's temp browser / mobile work area. Once the entire image has been recreated on the client side - then assign the image file to the Appeon Web/Mobile Apps appropriate image control.
Note: You could also optimize the Blob interactions by controlling the FileRead command loop as to when the UpdateBlob command is fired. That is for example, have an App INI file setting that set's the "trigger" point when the UpdateBlob command is to used. Thus, you could have the loop write 64K, 128K, 256K, etc blob chunks to the TEMP table instead of just the 32K default. Thus, allowing you to optimize the network traffic and Blob processing overhead of your DBMS via an INI setting.
Food for thought. HTH
Regards ... Chris
Appeon: Director, Developer Relations.
Here's another response, this one from Ganesh Babu:
Hi
You cannot save DOC or BMP file directly into database..B4 saving into DB you have to convert into BLOB. Here i attached 2 functions for to convert 1. file into blob 2. blob into file..
Try this method and let me know...
Thanx and Regards
GANESH BABU
f_create_blob_from_file(is_cur_doc_name (string,pass by value),
lblb_doc (blob pass by reference))
-----------------------------------------------------------------
Long ll_flen,ll_FileNum,ll_loops_cnt,i,ll_bytes_read
Blob lb
SetPointer(HourGlass!)
// Get the file length, and open the file
ll_flen = FileLength(as_file_name)
ll_FileNum = FileOpen(as_file_name,StreamMode!, Read!, LockRead!)
// Determine how many times to call FileRead
IF ll_flen > 32765 THEN
IF Mod(ll_flen, 32765) = 0 THEN
ll_loops_cnt = ll_flen/32765
ELSE
ll_loops_cnt = (ll_flen/32765) + 1
END IF
ELSE
ll_loops_cnt = 1
END IF
FOR i = 1 to ll_loops_cnt
ll_bytes_read = FileRead(ll_FileNum, lb)
ablb_image_dtl = ablb_image_dtl + lb
NEXT
FileClose(ll_FileNum)
f_blob_into_file(ls_doc_name(string,pass by value),
ls_doc_path (string,pass by value),
lblb_image (blob pass by reference))
-----------------------------------------------------
String ls_path_name, ls_extend
Long ll_flen,ll_filenum,ll_loops_cnt,i,ll_retLong ll_bytes_read,ll_posString
Blob lb
ls_path_name = as_path_name + as_filename
as_path_name = ls_path_name
SetPointer(HourGlass!)
// Get the file length, and open the file
ll_flen = Len(ablb_image_dtl)
ll_FileNum = FileOpen(ls_path_name,StreamMode!,Write!,Shared!,Replace!)
// Determine how many times to call FileRead
IF ll_flen > 32765 THEN
IF Mod(ll_flen, 32765) = 0 THEN
ll_loops_cnt = ll_flen/32765
ELSE
ll_loops_cnt = (ll_flen/32765) + 1
END IF
ELSE
ll_loops_cnt = 1
END IF
FOR i = 1 to ll_loops_cnt
ll_ret = FileWrite(ll_FileNum, ablb_image_dtl)
ablb_image_dtl = BLOBMID (ablb_image_dtl,ll_ret+1)
NEXT
FileClose(ll_FileNum)
RETURN 1
Good Luck,
Olan
Hi Kevin;
It's because the image file(s) may be "huge". FileRead allows you to "chunk" the datum into manageable pieces. Whereas the FileReadEx forces you to take the datum in its entirety. Which in turn, then forces you to deal with your software / hardware limitations.
HTH
Regards ... Chris
I don't understand why you would want to loop and use FileRead when there's a FileReadEx that can get it done in 1 call with no loop.