Error while reading blob from database with Pro*c code
From: Neo <vashisht_r_at_yahoo.com>
Date: 22 Aug 2003 08:52:41 -0700
Message-ID: <697f87bc.0308220752.679b7dfb_at_posting.google.com>
Hi All,
[Quoted] [Quoted] I am trying to read blobs through Pro*c code. When the blob value is read within on shot it works fine but the moment my code tries to get this value by polling it gives absurd results. Mostly it returns junk values in alternate retrieves.
The code snippet is as below
Date: 22 Aug 2003 08:52:41 -0700
Message-ID: <697f87bc.0308220752.679b7dfb_at_posting.google.com>
Hi All,
[Quoted] [Quoted] I am trying to read blobs through Pro*c code. When the blob value is read within on shot it works fine but the moment my code tries to get this value by polling it gives absurd results. Mostly it returns junk values in alternate retrieves.
The code snippet is as below
dbContext = connectInfo->context;
strcpy(connectStr,(connectInfo->connectName).c_str());
EXEC SQL CONTEXT USE :dbContext;
sqlId = id.c_str();
EXEC SQL BEGIN DECLARE SECTION; OCIBlobLocator *readBlob; int amt; // --- Used for reading as multiple blocks of size 1024 char rBuffer[1024]; EXEC SQL END DECLARE SECTION; amt = 0; EXEC SQL VAR rBuffer is RAW(1024); EXEC SQL AT :connectStr ALLOCATE :readBlob; //------------------------ READ AS A MULTIPLE BLOCKS ------------------------ string finalStr = ""; char tmpChar[5000]; EXEC SQL AT :connectStr SELECT DATA INTO :readBlob FROM mds_mqdefinition WHERE ID = :sqlId; if(sqlca.sqlcode != 0)
{
cout << "Error while reading the blob" << endl; return sqlca.sqlcode; } do
{
EXEC SQL AT :connectStr LOB READ :amt FROM :readBlob INTO :rBuffer; cout <<"sqlca.code " << sqlca.sqlcode << endl; memcpy(tmpChar,rBuffer,amt); tmpChar[amt] = '\0'; string tmpStr(tmpChar); finalStr +=tmpStr; }while(sqlca.sqlcode==0); EXEC SQL AT :connectStr FREE :readBlob; cout << "FINAL CMD STRING : " << "<"<< finalStr<<">" << endl; ----------------------------------------------------
I have checked various options but the results are very inconsistent. Any help us most appreciated.
Platform - linux 7.2
Oracle 7.x
gnu 2.9.6 c++ compiler.
Regards,
Neo
Received on Fri Aug 22 2003 - 17:52:41 CEST