On 12/21/06, E Tse <[EMAIL PROTECTED]> wrote:
Hi guys,
I ran into a strange problem. I have 2 prepared sqlite3_stmt, each inserting
to different tables in a sqlite database:

sqlite3_stmt* insertA;
std::string sql = "insert into tablea(col1) values(?)";
int rc = sqlite3_prepare(db_, sql.c_str(), sql.size(), &insertA, NULL);

sqlite3_stmt* insertB;
std::string sql = "insert into tableb(col1) values(?)";
int rc = sqlite3_prepare(db_, sql.c_str(), sql.size(), &insertB, NULL);

I intended to keep insertA and insertB through the lifetime of my
application/database. I use sqlite3_reset(insertA) before and after each
$sqlite3_step() call:

sqlite3_reset(insertA);
sqlite3_bind_int(insertA, ...);
rc1 = sqlite3_step(insertA);
sqlite3_reset(insertA);

sqlite3_reset(insertB);
sqlite3_bind_int(insertB, ...);
rc2 = sqlite3_step(insertB);
sqlite3_reset(insertB);

The strange thing is rc2 will returns SQLITE_ERROR if sqlite3_step(insertA)
is executed. The error message from sqlite3_errmsg() is even stranger. It
returns "not an error"!

It looks like your code written so it will reset() the statement
before it's executed
the first time. Perhaps you shouldn't do a reset unless it's been executed.

like

prepare()
while ( something )
  bind()
  step()
  reset()


--
The PixAddixImage Collector suite:
http://groups-beta.google.com/group/pixaddix

SqliteImporter and SqliteReplicator: Command line utilities for Sqlite
http://www.reddawn.net/~jsprenkl/Sqlite

Cthulhu Bucks!
http://www.cthulhubucks.com

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

Reply via email to