void select_by_prepare (sqlite3* pDB){
 51     int i;
 52     int ret = 0;
 53     int time;
 54     char* pdu;
 55     int pdu_size;
 56     int flag;
 57     sqlite3_stmt *statement;
 58 
 59     ret = sqlite3_prepare (pDB, "SELECT * FROM content", -1, &statement, NULL);
 60     if(ret != SQLITE_OK){
 61         printf("prepare error ret : %d\n", ret);
 62         return;
 63     }
 64 
 65     while (sqlite3_step(statement) == SQLITE_ROW) {
 66         time = sqlite3_column_int(statement, 0);
 67         pdu = (char *)sqlite3_column_text(statement, 1);
 68         pdu_size = sqlite3_column_int (statement, 2);
 69         flag = sqlite3_column_int (statement, 3);
 70 
 71         printf("step row num : %d, %s, %d, %d\n", time, pdu, pdu_size, flag);
 72     }
 73 
 74     sqlite3_finalize(statement);
75 }

int sqlite3_step(sqlite3_stmt*);
the return value will be either SQLITE_BUSYSQLITE_DONESQLITE_ROWSQLITE_ERROR, or SQLITE_MISUSE

SQLITE_BUSY means that the database engine was unable to acquire the database locks it needs to do its job. If the statement is a COMMIT or occurs outside of an explicit transaction, then you can retry the statement. If the statement is not a COMMIT and occurs within an explicit transaction then you should rollback the transaction before continuing.

SQLITE_DONE means that the statement has finished executing successfully. sqlite3_step() should not be called again on this virtual machine without first callingsqlite3_reset() to reset the virtual machine back to its initial state.

If the SQL statement being executed returns any data, then SQLITE_ROW is returned each time a new row of data is ready for processing by the caller. The values may be accessed using the column access functions. sqlite3_step() is called again to retrieve the next row of data.

SQLITE_ERROR means that a run-time error (such as a constraint violation) has occurred. sqlite3_step() should not be called again on the VM. More information may be found by calling sqlite3_errmsg(). With the legacy interface, a more specific error code (for example, SQLITE_INTERRUPTSQLITE_SCHEMASQLITE_CORRUPT, and so forth) can be obtained by calling sqlite3_reset() on the prepared statement. In the "v2" interface, the more specific error code is returned directly by sqlite3_step().

SQLITE_MISUSE means that the this routine was called inappropriately. Perhaps it was called on a prepared statement that has already been finalized or on one that had previously returned SQLITE_ERROR or SQLITE_DONE. Or it could be the case that the same database connection is being used by two or more threads at the same moment in time.


const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
double sqlite3_column_double(sqlite3_stmt*, int iCol);
int sqlite3_column_int(sqlite3_stmt*, int iCol);
sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
int sqlite3_column_type(sqlite3_stmt*, int iCol);
sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);

sqlite3 sqlite3_prepare、sqlite3_step使用的更多相关文章

  1. [转]SQLITE3 C语言接口 API 函数简介

    SQLITE3 C语言接口 API 函数简介 说明:本说明文档属作者从接触 SQLite 开始认识的 API 函数的使用方法, 由本人翻译, 不断更新. /* 2012-05-25 */ int sq ...

  2. iOS sqlite3数据库解析

    看来从版本3.3.1基本上已经支持线程句柄的传递功能.具体限制我标记了一下.(6) Is SQLite threadsafe?SQLite is threadsafe. We make this co ...

  3. sqlite3使用简介(内含解决sqlite内存的方法)

    一.使用流程 要使用sqlite,需要从sqlite官网下载到三个文件,分别为sqlite3.lib,sqlite3.dll,sqlite3.h,然后再在自己的工程中配置好头文件和库文件,同时将dll ...

  4. SQLite3简单入门及C++ API

    转载请注明出处:http://www.cnblogs.com/StartoverX/p/4660487.html 项目用到SQLite3,简单记录一下. MySQL不同,SQLite3的数据库基于文件 ...

  5. SQLite3命令操作大全

    SQLite3命令操作大全 SQLite库包含一个名字叫做sqlite3的命令行,它可以让用户手工输入并执行面向SQLite数据库的SQL命令.本文档提供一个样使用sqlite3的简要说明. 一.ql ...

  6. sqlite3常用指令

    一.建立数据库 sqlite3.exe test.db 二.双击sqlite-3_6_16目录下的程序sqlite3.exe,即可运行 三.退出 .exit 或者 .quit 四.SQLite支持如下 ...

  7. C 扩展库 - sqlite3 API

    sqlite3 API Summary sqlite3 The database connection object. Created by sqlite3_open() and destroyed ...

  8. sqlite3使用简介

    sqlite3使用简介 一.使用流程 要使用sqlite,需要从sqlite官网下载到三个文件,分别为sqlite3.lib,sqlite3.dll,sqlite3.h,然后再在自己的工程中配置好头文 ...

  9. 我的Android进阶之旅------>温习Sqlite3的常用操作

    前言;今天要写一个应用来调节系统的Brightness值,来改变系统的背光亮度.由于刚开始些的时候没有考虑Brightness的最小值,直接托动SeekBar到最小值(为0).瞬间,屏幕变成全黑,失败 ...

随机推荐

  1. python的算法:二分法查找(2)--bisect模块

    Python 有一个 bisect 模块,用于维护有序列表.bisect 模块实现了一个算法用于插入元素到有序列表.在一些情况下,这比反复排序列表或构造一个大的列表再排序的效率更高.Bisect 是二 ...

  2. PDCurses 笔记(一)

    之前没有接触过curse和ncurse,平时用的也都是windows系统,所以对PDCurses也挺感兴趣的.网上关于PDCurses的内容也不是很多,但是感觉上它的函数应该都是和其他操作系统里函数都 ...

  3. Python 进阶 之 socket模块

    Python Socket 编程详细介绍 转载地址:https://gist.github.com/kevinkindom/108ffd675cb9253f8f71?signup=true Pytho ...

  4. 大数据量的Mysql数据库备份策略

    Centos下mysql常用的三种备份方法 http://www.centoscn.com/CentOS/Intermediate/2013/0807/1160.html xtrabackup备份 h ...

  5. [BZOJ3585]mex 主席树

    3585: mex Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 1252  Solved: 639[Submit][Status][Discuss] ...

  6. 【转】appium常用方法整理

    1.相对坐标解锁九宫格 应用场景 QQ解锁屏幕如上,可见九个按键在同一个View下面,要实现解锁,用press   moveTo  release  perform方法 实现代码如下: WebElem ...

  7. Oralce聚合多行

    拼接的字符串长度满足varchar2(4000)时, 可以用 LISTAGG(NAME, '_') WITHIN GROUP(ORDER BY LEVEL_T DESC) 当拼接大段文本时,采用 10 ...

  8. CSS 从入门到放弃系列:CSS的选择器和优先级

    CSS的选择器和优先级 CSS的N种选择器 !important 其实这个玩意不算什么选择器,放在这只是为了突出这个选择器优先级或者说权重的从高到低而已.. 内联方式(行间样式) <div st ...

  9. 11.5NOIP2018提高组模拟题

    书信(letter) Description 有 n 个小朋友, 编号为 1 到 n, 他们每人写了一封信, 放到了一个信箱里, 接下来每个人从中抽取一封书信. 显然, 这样一共有 n!种拿到书信的情 ...

  10. NGUI_Sprites

    一.UI Sprites 控件: Sprites控件是NGUI的基础控件,几乎可以这么说所有的控件都可以基于Sprites控件添加 Box Collider然后进行附加相关的脚本组件来达到想要的插件效 ...