Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

psr help ?? 1

Status
Not open for further replies.

rjoshi2

Programmer
Sep 10, 2002
110
0
0
US
I have inserted a psr report as a blob in my database (oracle8i). I have not been able to view this report in powerbuilder. I have been able to view other formats (wmf, gif) that I have that I inserted as blob. Is it possible for powerbuilder 6.5 to display psr reports (how)?

Thank You,
rjoshi2
 
If you want to view the PSR files that you 'saved' into the dB, you will have to retrieve the blob into a var, save it to a temporary PSR-file on the hard-disk and assign this temporary file with its full path to the dw.DataObject to view it at runtime.

---
PowerObject!
-----------------------------------------
PowerBuilder / PFC Developers' Group
 
PowerObject,

Could you please tell me what you mean by var (variable)?
What type of variable do I retrieve the blob into?

Thank You,
rjoshi2
 
Var is a shortform for variable.

Typically, you would use the SELECTBLOB SQL statement to retrieve the file in a blob variable (the opposite way of how you inserted the PSR into the dB). See Help on low-level file functions such as FileRead(), FileWrite()... and the 'Examples' in them on how to write/dump the contents of a blob var to a file.

---
PowerObject!
-----------------------------------------
PowerBuilder / PFC Developers' Group
 
(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)
 
Have you inserted the PSR file itself into the dB or just an image of the PSR? If it is the PSR file itself, all you have to do is to assign the written-file to the dw (after you read it from the dB and successfully write to a temp file):

dw.DataObject = "C:\Documents and Settings\administrator\Desktop\testing.psr"

Basically, you would read the blob dat ainto a var, 'write' it to a temp file and 'assign' the file-name to the dw.DataObject. That's all there is to it!

However, if you saved an image of the PSR into the dB, you may have to use a Picture control and do a SetPicture() on it (in this case, you don't need to write to a temp file).

Hope this helps...

---
PowerObject!
-----------------------------------------
PowerBuilder / PFC Developers' Group
 
PowerObject,

I have you inserted the PSR file itself into the dB. I have been successful in viewing the psr report. My question is how could you insert the image of the PSR file? Could you post an oracle/powerbuilder procedure/function that will insert the image of the psr?

Thank You,
rjoshi2


 
It's not possible to save an entire/multi-page PSR to a graphic file using code. I thought you might have done a screenshot (Alt+PrintScreen) on a one-page report.

---
PowerObject!


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top