所有的SQLite返回码见下表。所有能够返回这些码的函数包括:
sqlite3_bind_xxx()
sqlite3_close()
sqlite3_create_collation()
sqlite3_collation_needed()
sqlite3_create_function()
sqlite3_prepare()
sqlite3_exec()
sqlite3_finalize()
sqlite3_get_table()
sqlite3_open()
sqlite3_reset()
sqlite3_step()
sqlite3_transfer_bindings()
可以使用函数sqlite3_errmsg()获得附加的错误信息,其声明如下:
const char *sqlite3_errmsg(sqlite3 *);
它以一个连接句柄作参数,返回该连接最近的一条错误信息。如果还没有发生错误,它返回“not an error”。
表: SQLite的返回码
返回码 |
说明 |
SQLITE_OK |
The operation was successful. |
SQLITE_ERROR |
General SQL error or missing database. It may be possible to obtain more error information depending on the error condition (SQLITE_SCHEMA, for example). |
SQLITE_PERM |
Access permission denied. Cannot read or write to the database file. |
SQLITE_ABORT |
A callback routine requested an abort. |
SQLITE_BUSY |
The database file is locked. |
SQLITE_LOCKED |
A table in the database is locked. |
SQLITE_NOMEM |
A call to malloc() has failed within a database operation. |
SQLITE_READONLY |
An attempt was made to write to a read-only database. |
SQLITE_INTERRUPT |
Operation was terminated by sqlite3_interrupt(). |
SQLITE_IOERR |
Some kind of disk I/O error occurred. |
SQLITE_CORRUPT |
The database disk image is malformed. This will also occur if an attempt is made to open a non-SQLite database file as a SQLite database. SQLITE_FULL Insertion failed because the database is full. There is no more space on the file system or the database file cannot be expanded. |
SQLITE_CANTOPEN |
SQLite was unable to open the database file. |
SQLITE_PROTOCOL |
The database is locked or there has been a protocol error. |
SQLITE_EMPTY |
(Internal only) The database table is empty. |
SQLITE_SCHEMA |
The database schema has changed. |
SQLITE_CONSTRAINT |
Abort due to constraint violation. This constant is returned if the SQL statement would have violated a database constraint (such as attempting to insert a value into a unique index that already exists in the index). |
SQLITE_MISMATCH |
Data type mismatch. An example of this is an attempt to insert non-integer data into a column labeled INTEGER PRIMARY KEY. For most columns, SQLite ignores the data type and allows any kind of data to be stored. But an INTEGER PRIMARY KEY column is only allowed to store integer data. |
SQLITE_MISUSE |
Library was used incorrectly. This error might occur if one or more of the SQLite API routines is used incorrectly. Examples of incorrect usage include calling sqlite3_exec() after the database has been closed using sqlite3_close() or calling sqlite3_exec() with the same database pointer simultaneously from two separate threads. |
SQLITE_NOLFS |
Uses OS features not supported on host. This value is returned if the SQLite library was compiled with large file support (LFS) enabled but LFS isn’t supported on the host operating system. |
SQLITE_AUTH |
Authorization denied. This occurs when a callback function installed using sqlite3_set_authorizer() returns SQLITE_DENY. |
SQLITE_ROW |
sqlite3_step() has another row ready. |
SQLITE_DONE |
sqlite3_step() has finished executing. |