sqlite3.h的常用宏定义,错误代码(SQLITE_OK、SQLITE_BUSY等)

6 篇文章 0 订阅

许多SQLite函数从这里显示的集合中返回一个整数结果代码,以指示成功或失败。
如 sqlite3_open 、sqlite3_get_table、 sqlite3_exec函数的返回值

/*
** CAPI3REF: Result Codes
** KEYWORDS: SQLITE_OK {error code} {error codes}
** KEYWORDS: {result code} {result codes}
**
** Many SQLite functions return an integer result code from the set shown
** here in order to indicate success or failure.
**
** New error codes may be added in future versions of SQLite.
**
** See also: [SQLITE_IOERR_READ | extended result codes],
** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes].
*/
#define SQLITE_OK           0   /* Successful result */
/* beginning-of-error-codes */
#define SQLITE_ERROR        1   /* SQL error or missing database */
#define SQLITE_INTERNAL     2   /* Internal logic error in SQLite */
#define SQLITE_PERM         3   /* Access permission denied */
#define SQLITE_ABORT        4   /* Callback routine requested an abort */
#define SQLITE_BUSY         5   /* The database file is locked */
#define SQLITE_LOCKED       6   /* A table in the database is locked */
#define SQLITE_NOMEM        7   /* A malloc() failed */
#define SQLITE_READONLY     8   /* Attempt to write a readonly database */
#define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/
#define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */
#define SQLITE_CORRUPT     11   /* The database disk image is malformed */
#define SQLITE_NOTFOUND    12   /* Unknown opcode in sqlite3_file_control() */
#define SQLITE_FULL        13   /* Insertion failed because database is full */
#define SQLITE_CANTOPEN    14   /* Unable to open the database file */
#define SQLITE_PROTOCOL    15   /* Database lock protocol error */
#define SQLITE_EMPTY       16   /* Database is empty */
#define SQLITE_SCHEMA      17   /* The database schema changed */
#define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */
#define SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */
#define SQLITE_MISMATCH    20   /* Data type mismatch */
#define SQLITE_MISUSE      21   /* Library used incorrectly */
#define SQLITE_NOLFS       22   /* Uses OS features not supported on host */
#define SQLITE_AUTH        23   /* Authorization denied */
#define SQLITE_FORMAT      24   /* Auxiliary database format error */
#define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */
#define SQLITE_NOTADB      26   /* File opened that is not a database file */
#define SQLITE_NOTICE      27   /* Notifications from sqlite3_log() */
#define SQLITE_WARNING     28   /* Warnings from sqlite3_log() */
#define SQLITE_ROW         100  /* sqlite3_step() has another row ready */
#define SQLITE_DONE        101  /* sqlite3_step() has finished executing */
/* end-of-error-codes */

机翻

#define SQLITE_OK         0 /*成功结果*/
#define SQLITE_ERROR      1 /*SQL错误或缺少数据库*/
#define SQLITE_INTERNAL   2 /*SQLite中的内部逻辑错误*/
#define SQLITE_PERM       3 /*访问权限被拒绝*/
#define SQLITE_ABORT      4 /*回调例程请求中止*/
#define SQLITE_BUSY       5 /*数据库文件已锁定*/
#define SQLITE_LOCKED     6 /*数据库中的一个表被锁定*/
#define SQLITE_NOMEM      7 /*一个malloc()失败*/
#define SQLITE_READONLY   8 /*尝试写入只读数据库*/
#define SQLITE_INTERRUPT  9 /*由sqlite3_interrupt()终止的操作*/
#define SQLITE_IOERR      10 /*发生某种磁盘I/O错误*/
#define SQLITE_CORRUPT    11 /*数据库磁盘映像格式不正确*/
#define SQLITE_NOTFOUND   12 /*未知操作码sqlite3_interrupt()*/
#define SQLITE_FULL       13 /*插入失败,因为数据库已满*/
#define SQLITE_CANTOPEN   14 /*无法打开数据库文件*/
#define SQLITE_PROTOCOL   15 /*数据库锁协议错误*/
#define SQLITE_EMPTY      16 /*数据库为空*/
#define SQLITE_SCHEMA     17 /*数据库架构已更改*/
#define SQLITE_TOOBIG     18 /*字符串或BLOB超出大小限制*/
#define SQLITE_CONSTRAINT 19 /*由于约束冲突而中止*/
#define SQLITE_MISMATCH   20 /*数据类型不匹配*/
#define SQLITE_usage      21 /*库使用错误*/
#define SQLITE_NOLFS      22 /*使用主机不支持的操作系统功能*/
#define SQLITE_AUTH       23 /*授权被拒绝*/
#define SQLITE_FORMAT     24 /*辅助数据库格式错误*/
#define SQLITE_RANGE      25 /*第二个参数定义为sqlite3_bind超出范围*/
#define SQLITE_NOTADB     26 /*打开的不是数据库文件的文件*/
#define SQLITE_NOTICE     27 /*来自sqlite3_log()的通知*/
#define SQLITE_WARNING    28 /*来自sqlite3_log()的警告*/
#define SQLITE_ROW        100 /*sqlite3_step()已准备好另一行*/
#define SQLITE_DONE       101 /*sqlite3_step()已完成执行*/

补充

SQLITE_API int sqlite3_open(
  const char *filename,   /* Database filename (UTF-8) */
  sqlite3 **ppDb          /* OUT: SQLite db handle */
);

SQLITE_API int sqlite3_exec(
  sqlite3*,                                  /* An open database */
  const char *sql,                           /* SQL to be evaluated */
  int (*callback)(void*,int,char**,char**),  /* Callback function */
  void *,                                    /* 1st argument to callback */
  char **errmsg                              /* Error msg written here */
);

SQLITE_API int sqlite3_get_table(
  sqlite3 *db,          /* An open database */
  const char *zSql,     /* SQL to be evaluated */
  char ***pazResult,    /* Results of the query */
  int *pnRow,           /* Number of result rows written here */
  int *pnColumn,        /* Number of result columns written here */
  char **pzErrmsg       /* Error msg written here */
);
SQLITE_API void sqlite3_free_table(char **result);

  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Love丶伊卡洛斯

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值