On 8/17/07, Scott Derrick <[EMAIL PROTECTED]> wrote: > exec a "BEGIN IMMEDIATE", with a sleep loop if I can't acquire the > reserved lock. > > Then prepare, step, finalize, exit the function > > When I come back into the function and exec a "BEGIN IMMEDIATE" I get an > error > > "Cannot start a transaction within a transaction". > > Whats wrong? Doesn't sqlite3_finalize(stmt), release the locks, > deletes the prepared statement and causes the database to be updated?
It deletes the prepared statement. The statement's action would have been performed by a previous sqlite3_step(). Locks and database updates are another matter, because... > Why does the engine think I'm still in a transaction? ...you started a transaction with BEGIN. Unless the statement you stepped is a COMMIT, your transaction isn't done yet :) Exec a COMMIT at the end of the loop. Incidentally, you can keep the prepared statement around if it's appropriate. You can open the database, prepare the statement, and only step() and reset() within the loop. This way you don't have to keep preparing it over and over again. You must finalize() it before closing the database, though. ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------