original SQL text---<sqlite3_prepare_v2>--->sqlite3_stmt--<sqlite3_reset>-->clear sqlite3_stmt --<sqlite3_bind_*(stmt,1,*)>--> configed sqlite3_stmt

--<sqlite3_step()>--->run sqlite3_stmt---<sqlite3_column_*(statement, N)>--->查询输出----<sqlite3_finalize()>--->释放语句

/*

** CAPI3REF: Prepared Statement Object

** KEYWORDS: {prepared statement} {prepared statements}

**

** An instance of this object represents a single SQL statement that

** has been compiled into binary form and is ready to be evaluated.

**

** Think of each SQL statement as a separate computer program.  The

** original SQL text is source code.  A prepared statement object

** is the compiled object code.  All SQL must be converted into a

** prepared statement before it can be run.

**

** The life-cycle of a prepared statement object usually goes like this:

**

** <ol>

** <li> Create the prepared statement object using [sqlite3_prepare_v2()].

** <li> Bind values to [parameters] using the sqlite3_bind_*()

**      interfaces.

** <li> Run the SQL by calling [sqlite3_step()] one or more times.

** <li> Reset the prepared statement using [sqlite3_reset()] then go back

**      to step 2.  Do this zero or more times.

** <li> Destroy the object using [sqlite3_finalize()].

** </ol>

-(void)select{

NSString * sqlString = @"select * from person";

//准备sql语句

sqlite3_stmt * stmt = nil;

sqlite3_prepare(db, sqlString.UTF8String, -1, &stmt, nil);

//单步执行语句

while (sqlite3_step(stmt) == SQLITE_ROW) {

const unsigned char * name = sqlite3_column_text(stmt, 0);

NSString * nameStr = [NSString stringWithUTF8String:(const char*)name];

int age = sqlite3_column_int(stmt, 1);

NSLog(@"name:::%@ and age:::%d",nameStr,age);

}

//释放

sqlite3_finalize(stmt);

}

最新文章

  1. python网络编程-TCP协议中的三次握手和四次挥手(图解)
  2. 【转】Native JavaScript Data-Binding
  3. Delphi基础语法的学习笔记和注意事项总结
  4. 转 SQL Union和SQL Union All两者用法区别效率以及与order by 和 group by配合问题
  5. Contoso 大学 - 7 – 处理并发
  6. VS2012、VS2010、VS2008常用的快捷键
  7. BZOJ 1022 [SHOI2008]小约翰的游戏John
  8. MySQL实用基础笔记
  9. centos 安装mysql密码修改后还是不能连接的原因
  10. 每天学点SpringMVC-异常处理
  11. 关于离线底图和离线shp文件的加载
  12. 骗子网站,X毛都没有,骗我九十九
  13. BZOJ 3817 Sum
  14. 剑指offer:链表中倒数第k个结点
  15. python输入整数
  16. socket编程-阻塞和非阻塞
  17. WebApp专家评委打分的两种进入模式
  18. binding(转)
  19. OSI、TCP、IP、UDP 这些都是啥??
  20. wsdl.exe的用法与参数说明

热门文章

  1. 【微服务No.3】AOP组件ASPectCore简单使用
  2. swoole扩展实现真正的数据库连接池
  3. 45.work_struct和delayed_work的工作队列使用
  4. 我永远喜欢着OOP——第一次总结
  5. Python 集合符号
  6. Python 语法笔记
  7. eclipse安装阿里编码规约插件
  8. 苹果手机如何投屏到win10电脑上
  9. iOS------获取当前时间和当前时间戳
  10. 改变RadioButton的文字位置以及距离