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).瞬间,屏幕变成全黑,失败 ...
随机推荐
- redis发布订阅、HyperLogLog与GEO功能的介绍
一.发布订阅 1.模型 发布者发布消息,订阅者接收消息 2.API 2.1.publish 2.2.订阅 2.3.取消订阅 unsubsribe 2.4.其他api 二.HyperLogLog 极小空 ...
- AC日记——平衡树练习 codevs 4244
4244 平衡树练习 思路: 有节操的人不用set也不用map: 代码: #include <cstdio> #include <cstring> #include <i ...
- (19)python扩展
当python程序遇到瓶颈时,可以考略扩展其他语言 例如:程序的某部分,需要高速度,或者与硬件交互时可以用到C语言.当其他语言有现成的程序,重新起来很麻烦时.有些功能用别的语言写更方便时 扩展语言有 ...
- ZCMU训练赛-B(dp/暴力)
B - Break Standard Weight The balance was the first mass measuring instrument invented. In its tradi ...
- HDU 2045 LELE的RPG难题(递推)
不容易系列之(3)—— LELE的RPG难题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/O ...
- 24、Django实战第24天:讲师列表页
1.复制teracher-list.html到templates目录下 2.编辑teacher-list.html,继承base模板 3.编辑organization.views.py ... fro ...
- [Contest20180415]看无可看
题意:有一个数列$f$,对$\forall i\geq2,f_i=2f_{i-1}+3f_{i-2}$,给定$f_0,f_1$,再给定一个集合$S=\{a_{1\cdots n}\}$和$k$,求$\ ...
- 【主席树】bzoj2588 Spoj 10628. Count on a tree
每个点的主席树的root是从其父转移来的.询问的时候用U+V-LCA-FA(LCA)即可. #include<cstdio> #include<algorithm> using ...
- 【点分治】bzoj2152 聪聪可可
模板题. #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> ...
- 5.9 j(java学习笔记)强软弱虚引用及WeakHashMap、IdentityHashMap、EnumMap
一.引用分类 强:运行垃圾回收机制后也不回收,程序出现内存溢出也不回收. 软:在垃圾回收机制运行时判断内存是否已满,如果内存已满则回收,内存充足则不回收. 弱:垃圾回收机制运行后不论内存是否充足都会立 ...