sqlite3 sqlite3_prepare、sqlite3_step使用
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_BUSY, SQLITE_DONE, SQLITE_ROW, SQLITE_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_INTERRUPT, SQLITE_SCHEMA, SQLITE_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使用的更多相关文章
- [转]SQLITE3 C语言接口 API 函数简介
SQLITE3 C语言接口 API 函数简介 说明:本说明文档属作者从接触 SQLite 开始认识的 API 函数的使用方法, 由本人翻译, 不断更新. /* 2012-05-25 */ int sq ...
- iOS sqlite3数据库解析
看来从版本3.3.1基本上已经支持线程句柄的传递功能.具体限制我标记了一下.(6) Is SQLite threadsafe?SQLite is threadsafe. We make this co ...
- sqlite3使用简介(内含解决sqlite内存的方法)
一.使用流程 要使用sqlite,需要从sqlite官网下载到三个文件,分别为sqlite3.lib,sqlite3.dll,sqlite3.h,然后再在自己的工程中配置好头文件和库文件,同时将dll ...
- SQLite3简单入门及C++ API
转载请注明出处:http://www.cnblogs.com/StartoverX/p/4660487.html 项目用到SQLite3,简单记录一下. MySQL不同,SQLite3的数据库基于文件 ...
- SQLite3命令操作大全
SQLite3命令操作大全 SQLite库包含一个名字叫做sqlite3的命令行,它可以让用户手工输入并执行面向SQLite数据库的SQL命令.本文档提供一个样使用sqlite3的简要说明. 一.ql ...
- sqlite3常用指令
一.建立数据库 sqlite3.exe test.db 二.双击sqlite-3_6_16目录下的程序sqlite3.exe,即可运行 三.退出 .exit 或者 .quit 四.SQLite支持如下 ...
- C 扩展库 - sqlite3 API
sqlite3 API Summary sqlite3 The database connection object. Created by sqlite3_open() and destroyed ...
- sqlite3使用简介
sqlite3使用简介 一.使用流程 要使用sqlite,需要从sqlite官网下载到三个文件,分别为sqlite3.lib,sqlite3.dll,sqlite3.h,然后再在自己的工程中配置好头文 ...
- 我的Android进阶之旅------>温习Sqlite3的常用操作
前言;今天要写一个应用来调节系统的Brightness值,来改变系统的背光亮度.由于刚开始些的时候没有考虑Brightness的最小值,直接托动SeekBar到最小值(为0).瞬间,屏幕变成全黑,失败 ...
随机推荐
- zoj3256
好题,由m的范围知道这肯定是矩阵乘法加速插头dp,关键是怎么写 以往插头dp常用逐格递推,而这道题要求整行逐列递推 这样我们才能构造转移矩阵. 我们可以通过假象一个第0列来将路径转化为回路问题 逐列递 ...
- win上使用nvm管理node版本
win上使用nvm管理node版本 若想让nvm管理机器上所有的node版本,首先需要卸载电脑上已有的node(很重要), 然后下载nvm在win上的安装包 windows-nvm的下载地址 下载 下 ...
- HDU 变形课 1181【DFS/BFS】
变形课 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Total Submissi ...
- Linux环境安装python3
linux 安装Python3 1.python下载 请在终端输入如下命令: cd /home wget http://cdn.npm.taobao.org/dist/python/3.6.5/Pyt ...
- 【数形结合】Gym - 100923I - Por Costel and the Pairs
perechi3.in / perechi3.out We don't know how Por Costel the pig arrived at FMI's dance party. All we ...
- 【前缀和】【前缀MAX】洛谷 P1351 NOIP2014提高组 day1 T2 联合权值
不难发现,树中与某个点距离为2的点只可能是它的父亲的父亲.儿子的儿子 或者 兄弟,分类讨论一下即可. 只有对于兄弟我们不能暴力搞,维护一下每个节点的所有儿子的前缀和.前缀MAX就行了. #includ ...
- 小白的Python之路 day4 不同目录间进行模块调用(绝对路径和相对路径)
一.常用模块调用函数功能解释 1.__file__ 功能:返回自身文件的相对路径 你从pycharm的执行结果可以看出,在pycharm执行atm.py文件时,是从绝对路径下去执行的,而你从cmd下去 ...
- 【OpenJudge9268】【递推】酒鬼
酒鬼 总时间限制: 2000ms 单个测试点时间限制: 1000ms 内存限制: 131072kB [描述] Santo刚刚与房东打赌赢得了一间在New Clondike 的大客厅.今天,他来到这个大 ...
- RxJava 2.x 理解-1
在RxJava 1.x 系列中,讲解了RxJava的大致用法,因为现在都用RxJava 2了,所以Rxjava 1就不细讲,主要来学习RxJava 2. 基本使用: /** * rajava2 的基本 ...
- Java杂谈4——Java中的字符串存储
Java中的String Java.Lang.String是Java语言自带的字符串实现,它并不是java的基本类型,但却和几乎每个java程序都密切相关的一个基础java类. string类内部实际 ...