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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run/exe problem with psr computed objects

Status
Not open for further replies.

rjoshi2

Programmer
Sep 10, 2002
110
US
The problem that I am having is that I am getting different result when run by project in powerbuilder and run it from an exe. I am trying to retrieve a psr from my oracle database (blob). Save it to local hard drive and then display it. It works fine when I run the project in powerbuilder I see all the data for reports (including computed objects). However, when I run this from executable computer object all show up as zero. Any help would be appreciated.

Thank You
rjoshi2

My Code:
integer li_FileNum, loops, i
blob b_file_pic, b_file_pic_temp, b, tot_b
long ll_len, flen, flen2, bytes_read, new_pos, bytes_write
string ls_report_name, ls_path

//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 bytSQLCB = Create Transactiones) for a single FileWrite call:
ls_report_name = dw_1.dataObject

if isnull(ls_path) = true or trim(ls_path) = '' then
ls_path = 'C:\DEMO2\report_pic\'+ ls_report_name + String(Today(), "yyyy-mm-dd")+ '.psr'
end if

if FileExists(ls_path) = FALSE then

transaction SQLCB
SQLCB = Create Transaction
SQLCB.DBMS="ODBC"
SQLCB.DBParm="ConnectString='DSN=demoora;UID=demo;PWD=sysadmin;'"

CONNECT USING SQLCB;

SELECTBLOB REPORT_PICTURE.REPORT_BLOB
INTO :b_file_pic
FROM REPORT_PICTURE
WHERE REPORT_PICTURE.REPORT_DW = :ls_report_name
USING SQLCB;

IF SQLCB.SQLCODE = 100 or SQLCB.SQLCODE <> 0 THEN
// MessageBox(&quot;Report Info&quot;, &quot;Sorry there is insufficient data available to provide this report.&quot;)
return
END IF

li_FileNum = FileOpen(ls_path, StreamMode!, Write!, Shared!, Replace!)

// Get the length of the b_file_pic
flen = len(b_file_pic)
// Determine how many times to call FileWrite
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

// Write the file
new_pos = 1

FOR i = 1 to loops

b_file_pic_temp = BlobMid(b_file_pic, ((32765 * i) - 32765 + 1), 32765)
bytes_write = FileWrite(li_FileNum, b_file_pic_temp)

NEXT
DISCONNECT USING SQLCB;
end if

//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
// flen2 = FileLength(ls_path)
//
// li_FileNum = FileOpen(ls_path, StreamMode!, Read!, LockRead!)
//
// // Determine how many times to call FileRead
// IF flen2 > 32765 THEN
//
// IF Mod(flen2, 32765) = 0 THEN
// loops = flen2/32765
// ELSE
// loops = (flen2/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
//
// FileClose(li_FileNum)

//turn redraw off to help avoid flicker
dw_1.setredraw(false)

// Display Report Picture
dw_1.DataObject = ls_path

//set redraw back on
dw_1.setredraw(true)

is_report_name = ''
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top