sqlite3_errcode() — Get error code for last failed API call


int sqlite3_errcode( sqlite3* db );

A database connection.


An error code or extended error code.


This function returns the error code from the last failed sqlite3_* API call associated with this database connection. If extended error codes are enabled, this function may also return an extended error code. If a failed call was followed by a successful call, the results are undefined.

If the SQLite library is in “serialized” threading mode, there is a risk of a race condition between threads. To avoid problems, the current thread should use sqlite3_mutex_enter() to acquire exclusive access to the database connection before the initial API call is made. The thread can release the mutex after sqlite3_errcode() is called. In “multi-thread” mode, it is the responsibility of the application to control access to the database connection.

If an API call returns SQLITE_MISUSE, it indicates an application error. In that case, the result code may or may not be available to sqlite3_errcode().

See Also

sqlite3_errmsg() [C API, Ap G], sqlite3_extended_result_codes() [C API, Ap G], sqlite3_extended_errcode() [C API, Ap G], sqlite3_mutex_enter() [C API, Ap G]

Get Using SQLite now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.