Hallo,
Has anyone an idea on how to bypass this problem ?

I'm about to write some abstraction-layer C++ class that implement some 
database and recordset function, using SQLite version 2.8.5.
My objects needs to step into rows and return row data one by one. This has 
been succesfully and easily implemented using the sqlite_compile, sqlite_step 
and sqlite_finalize functions. But, i've now a problem and i don't have found 
a valid solution:
during record navigation of a table i need to update some columns of that row. 
If the sqlite library is inside a virtual machine (between sqlite_compile and 
sqlite_finalize), any update statment that refer to the same table of the 
sql, returns whit the error SQLITE_BUSY

For example, imagine that my class has those mebers:
open(char*sql);
first();
next();
close();
update(const char *sql);

I do the following:

rec.open( "SELECT a, b from tab1" ); // this call the sqlite_compile
while ( !rec.eof() ) {
        rec.next(); // this call the sqlite_step
        if( a == 1 )
            rec.update ( "update tab1 set b=10 where a=1;" ); 
}

So, has anyone an idea on how to bypass this ?
Also, is there a way to save the "cursor" position of the rows navigation, and 
maybe use it later to restart navigation in the same position (or to uniquely 
identify a row of a sql) ?

Sometime the use of a unique id column it's not enough because a sql may be 
complex and may refer to some tables...

Any suggestion will be appreciated.

Thank you
Gabriele Brugnoni

Reply via email to