Sqlite的C API函数返回码的意义

所有的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.

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值