(1) My question is how do I display (in a datawindow) the report once it has been written to the file and then read by powerbuilder?
(2) Do you have to use the oracle driver (ODBC) to use the BLOB data type?
Any help would be appreciated.
Thank You,
rjoshi2
My Code:
blob b_file_pic, b, tot_b
long ll_len, flen, bytes_read, new_pos, bytes_write
//The following example reads a blob from the database and writes it to a file.
//The SQL SELECT statement assigns the picture data to the blob Emp_Id_Pic.
//Then FileOpen opens a file for writing in stream mode and FileWrite writes the blob to the file.
//You could use the Len function to test whether the blob was too big (>32,765 bytes) for a single FileWrite call:
SELECTBLOB REPORT_PICTURE.RPICTURE
INTO :b_file_pic
FROM REPORT_PICTURE
WHERE REPORT_PICTURE.RNUMBER = 2 ;
li_FileNum = FileOpen( &
"C:\Documents and Settings\administrator\Desktop\testing.psr", &
StreamMode!, Write!, Shared!, Replace!)
// Determine how many times to call FileWrite
IF flen > 32765 THEN
MessageBox("Lenght of the file", flen)
IF Mod(flen, 32765) = 0 THEN
loops = flen/32765
ELSE
loops = (flen/32765) + 1
END IF
ELSE
loops = 1
END IF
// Write the file
new_pos = 1
FOR i = 1 to loops
bytes_write = FileWrite(li_FileNum, b_file_pic)
tot_b = tot_b + b_file_pic
NEXT
//This example reads a file exceeding 32,765 bytes.
//After the script has read the file into the blob tot_b, you can call the SetPicture or
//String function to make use of the data, depending on the contents of the file:
//Get the file length, and open the file
flen = FileLength("C:\Documents and Settings\administrator\Desktop\testing.psr"
li_FileNum = FileOpen("C:\Documents and Settings\administrator\Desktop\testing.psr", &
StreamMode!, Read!, LockRead!)
// Determine how many times to call FileRead
IF flen > 32765 THEN
IF Mod(flen, 32765) = 0 THEN
loops = flen/32765
ELSE
loops = (flen/32765) + 1
END IF
ELSE
loops = 1
END IF
// Read the file
new_pos = 1
FOR i = 1 to loops
bytes_read = FileRead(li_FileNum, b)
tot_b = tot_b + b
NEXT
MessageBox("Write and Read", "Done"
//p_1.SetPicture(tot_b)
//dw_1.Retrieve(tot_b)
//dw_1.dataobject = tot_b
FileClose(li_FileNum)