- John Bailey
- PowerBuilder
- Friday, 11 August 2023 06:44 PM UTC
Being unsuccessful executing SELECTBLOB dynamically (using PB2021 with MSSQL Server DB).
The following in-line SQL code works:
blob lblob
SELECTBLOB pdf_blob INTO :lblob FROM web_pdf_backup_imagesWHERE backup_id = 102894 using it_DBTran;
Putting the above selectblob script into a string variable and execute immediate results in --Microsoft OLE DB Driver for SQL Server Incorrect syntax near the keyword 'INTO'
Figure I need to use a cursor to bind the parameters so tried --
string ls_sql
ls_sql = "SELECTBLOB pdf_blob FROM web_pdf_backup_images where backup_id = 103272
DECLARE cursor_blob DYNAMIC CURSOR FOR SQLSA ;
PREPARE SQLSA FROM :ls_sql USING it_DBTran ;
OPEN DYNAMIC cursor_blob ;
MessageBox("Open Cursor", it_DBTran.SQLErrText)
FETCH cursor_blob INTO :lblob ;
CLOSE cursor_blob ;
This resulted in the error --Microsoft OLE DB Driver for SQL Server Incorrect syntax near the keyword 'FROM'
After trying numerous variations, I decided to try getting a non-blob column using the above script
by replacing SELECTBLOB with SELECT and the column name and matching result vrbl.
This worked perfectly. So problem appears to be selecting the BLOB column dynamically.
Hopefully, someone can tell me how to get this to work, and then the next step which will be UPDATEBLOB.
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.