Hi,

 

I have a database which has a table that contains BLOB data. The table
has two columns - one is "Row_Num" which is of type AUTO_INCREMENT
(INTERGER_PRIMARY_KEY) and the other column "Data" contains BLOB data.

 

I am writing a program (in MS VC++) which has to read the blob data in
all the rows of the above mentioned table one after another. I am using
cppSQLite3 which is C++ wrapper function for accessing sqlite3 db. Mine
is an offline program that reads the data in the database which is
updated by another program.

 

I wrote the following code for reading from the database.

 

         CppSQLite3DB    db;

        CppSQLite3Buffer bufSQL;

 

        // Open the database. The name is provided by the user

        db.open(database_name);

        // Read the entire binary table

        bufSQL.format("select * from %s order by 1;",table_name);

        CppSQLite3Table b = db.getTable(bufSQL);

        CppSQLite3Binary blobz;

 

        // Read binary records one at a time from the database until all
the records are read

        for (int i=1;i <= b.numRows() ; i++)

        {

           CppSQLite3Query q; 

           CppSQLite3Buffer sql_command;

           long length = 0;

          

           // Read binary record from row number "i"

           sql_command.format("select Data from %s where Row_Num =
%d;",table_name,i);

           q = db.execQuery(sql_command);

           

           if (!q.eof())

           {

               blobz.setEncoded((unsigned char*)q.fieldValue("Data"));

               cout << "Retrieved binary Length: " <<
blobz.getBinaryLength() << endl;

           }

 

           const unsigned char* pbin = blobz.getBinary();

        }

 

This method works fine only when the table size is small. For example, I
have a database of size over 2GB in which case I get an error
SQLITE_NOMEM when I try to do db.gettable(). But i need to know the
number of rows in the table for reading BLOB data in each of the rows
one after another.

 

Please let me know how I can go about doing this?

Secondly, the column "Row_Num" is of type INTEGER_PRIMARY_KEY. So, it
will take negative value after 2GB as mine is a 32 bit machine.

So, how do I access data beyond 2 GB?

 

Please help me in this regard.

 

Regards,

Priya

 

Reply via email to