Hi Dave,

Dave Furey wrote:

Below is a very simplied example of what I'm trying to do with a recursive
routine call:

==========================================================

sqlite3_prepare (hDB,CstrCommand,strlen(CstrCommand),&ppStmt,&CstrTail);

while ( sqlite3_step(ppStmt) == SQLITE_ROW )
{ sqlite3_prepare
(hDB,CstrCommand2,strlen(CstrCommand2),&ppStmt2,&CstrTail2);
sqlite3_step(ppStmt2);
sqlite3_finalize(ppStmt2);
}


sqlite3_finalize(ppStmt);

sqlite3_prepare (hDB,CstrCommand3,strlen(CstrCommand3),&ppStmt3,&CstrTail);
sqlite3_step(ppStmt3);
sqlite3_finalize(ppStmt3);

==========================================================

Both the "CStrCommand" and "CStrCommand2" contain SELECT query statements.
This coding example works fine with the query (not returning any errors).
However, when I get to "CStrCommand3" (which contains an INSERT statement),
the sqlite3_step() call returns SQLITE_ERROR.

Is it legal for me to have the prepare/step/finalize coding embedded as I've
shown in my simple example above? Any help would be appreciated.


No, you cannot have nested queries on the same connection. To do that, you should:

a) Use two different connections, and
b) Compile with -DTHREAD_SAFE.

HTH

Ulrik P.



Reply via email to