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!

BLOB/Driver Question ????

Status
Not open for further replies.

rjoshi2

Programmer
Sep 10, 2002
110
US
Is it possible to write code that will change the driver that we are using to connect to our oracle 8i database? The reason I am asking is I am trying to retrieve blob in my powerbuilder 6.5 application but the Microsoft drivers do not support blob. I would like to switch to the oracle driver to retrieve the blob and switch back to the Microsoft driver. Any help would be appreciated.

Thank You,
rjoshi2
 
Switching the driver is not possible as this has to be done before the connection. You may instead use two transaction objects to make two connections and switch the transaction object doing dw.SetTransObject().

---
PowerObject!
-----------------------------------------
PowerBuilder / PFC Developers' Group
 
(1) I have tried to set a transaction object so I can retrieve and display a blob in a data window. I am not sure what is going wrong with my code. Could some please tell me what I am doing wrong. The program keeps crashing at line 2:

SQLCB.DBMS="ODBC" //Error: empty sting

(2) Do I have to set up a second transaction object connect back to the database or will my program use the existing (previous) connection after I disconnect?

Any help would be appreciated.

Thank You,
rjoshi2

My Code :

transaction SQLCB
SQLCB.DBMS="ODBC"
SQLCB.DBParm="ConnectString='DSN=OracleOracleDSN;UID=as_userid;PWD=as_password'"
CONNECT USING SQLCB;

integer li_FileNum, loops, i
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
USING SQLCB;

IF SQLCB.SQLCODE = 0 THEN
// everything OK
li_FileNum = FileOpen( &
"C:\Documents and Settings\administrator\Desktop\testing.psr", &
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
MessageBox("Lenght of the file is > then 32,765 bytes. It is ", 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
MessageBox("Lenght of the file is > then 32,765 bytes. It is ", flen)

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

FileClose(li_FileNum)

dw_1.DataObject = "C:\Documents and Settings\administrator\Desktop\testing.psr"
ELSE
MessageBox("Connection Error", "Please contact your computer Administrator.")
END IF
DISCONNECT USING SQLCB;


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top