Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Error while reading blob from database with Pro*c code

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@posting.google.com>


Hi All,
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 - 10:52:41 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US