I'm compiling a SQL statement (consisting of multiple statements separated
by semicolons) using sqlite3_prepare_v2 into a series of sqlite3_stmt
pointers, later to be executed with sqlite3_step().

A statement such as:

 DROP TABLE IF EXISTS test;
 CREATE TABLE test (id INTEGER, name TEXT);

is compiled into two sqlite3_stmt pointers that are subsequently fed
through sqlite3_step(): this works fine. That is, the first time I run the
program (and the database didn't exist upon program start). When I run the
program the 2nd time (and the database indeed exists upon program start)
the prepare_v2 bails out with ERROR and error 'table test already exists'.

When the statement above is fed through sqlite3_exec() the error does not
occur. When I had a look at the sqlite3_exec code it struck me that it
interleaves the calls to prepare/step/reset in a different way:

 prepare/step/reset prepare/step/reset

whereas I am trying to

 prepare/prepare step/step reset/reset

When I change my code to a similar interleaving scheme as sqlite3_exec I
dont have any problems.

My question is: is it indeed required to interleave the calls to
sqlite3_prepare_v2 and sqlite3_step in a similar way as sqlite3_exec does,
or should it be possible to fully precompile a series of statements which
then later can be executed?

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to