Olaf Beckman Lapré <[EMAIL PROTECTED]>
wrote:
I'm using a precompiled insert statement in a single transaction to
perform a bulk insert into a database table. I have a UNIQUE
constraint on the same table to prevent duplicate inserts and this
works well. However, I also want to detect and count the duplicate
inserts, but when I insert a duplicate row the error code that is
returned from the sqlite_step() function is SQLITE_ERROR and not
SQLITE_CONTRAINT as I would expect. I'm therefore unable to detect
whether the source of the error was from a duplicate insert or some
other error.

For historical reasons, sqlite3_step always* returns SQLITE_ERROR. The subsequent call to sqlite3_reset or sqlite3_finalize then returns an actual error code.

* Recent versions of SQLite support a new function, sqlite3_prepare_v2. If it is used to prepare a query, sqlite3_step returns error code directly.

Igor Tandetnik

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

Reply via email to