> On Mon, 2005-02-14 at 13:20 +0100, Ulrik Petersen wrote:
> > >
> > >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:
> >
>
> Actually, you can have nested queries. But inner queries are
> not allowed to update (or insert or delete) the tables used
> by outer queries.
> --
> D. Richard Hipp <[EMAIL PROTECTED]>
For the inner queries, I'm not inserting or updating, just doing a SELECT
statement. Once I'm done with the inner query, I then try to do an INSERT
and then I get the SQLITE_ERROR returned message from the sqlite3_step()
call. Am I doing something wrong? Or, do I need to open the database file
twice doing the following,
===============================================
/* CstrCommand contains a SELECT statement */
sqlite3_prepare (hDB,CstrCommand,strlen(CstrCommand),&ppStmt,&CstrTail);
while ( sqlite3_step(ppStmt) == SQLITE_ROW )
{
sqlite3_open("samedatabase.db",&hDB2);
/* CstrCommand2 contains a SELECT statement */
sqlite3_prepare(hDB2,CstrCommand2,strlen(CstrCommand2),&ppStmt2,&CstrTail2);
sqlite3_step(ppStmt2);
sqlite3_finalize(ppStmt2);
sqlite3_close(hDB2);
}
sqlite3_finalize(ppStmt);
/* CstrCommand3 contains a INSERT statement */
sqlite3_prepare (hDB,CstrCommand3,strlen(CstrCommand3),&ppStmt3,&CstrTail);
sqlite3_step(ppStmt3);
sqlite3_finalize(ppStmt3);
===============================================
Thanks,
Dave