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);

}

SQLite的sqlite3_prepare_v2的更多相关文章

  1. SQLite剖析之异步IO模式、共享缓存模式和解锁通知

    1.异步I/O模式    通常,当SQLite写一个数据库文件时,会等待,直到写操作完成,然后控制返回到调用程序.相比于CPU操作,写文件系统是非常耗时的,这是一个性能瓶颈.异步I/O后端是SQLit ...

  2. iOS开发数据库SQLite的使用

    iOS系统自带Core Data来进行持久化处理,而且Core Data可以使用图形化界面来创建对象,但是Core Data不是关系型数据库,对于Core Data来说比较擅长管理在设备上创建的数据持 ...

  3. iOS sqlite 的各种操作

    iOS --SQL的增加.删除.查找.修改 iOS对于数据库的操作:增加.删除.查找.修改 首先需要创建一个数据库:本程序的数据库是在火狐浏览器里的插件里写的微量型数据库 火狐找查找SQLite Ma ...

  4. SQLite使用(三)&&核心API使用

    概述     SQLite提供了一系列接口供用户访问数据库,主要包括连接数据库,处理SQL,迭代查询结果等.本文会针对我们使用SQLite的主要场景,列出核心的API,详细介绍API的用法并给出代码用 ...

  5. SQLite源程序分析之sqlite3.c

    /****************************************************************************** ** This file is an a ...

  6. SQLite

      什么是SQLite SQLite是一款轻型的嵌入式数据库 它占用资源非常的低,在嵌入式设备中,可能只需要几百K的内存就够了 它的处理速度比Mysql.PostgreSQL这两款著名的数据库都还快 ...

  7. 从SQLite获取数据完成一个产品信息展示

    在ios实际开发当中,我们常常用到Core Data做为数据储存首选.但在处理一些大量复杂的数据值且数据之间相互关联的时候,这就不得不使用关系型数据库来实现.例如一个导航程序,自身应该包含大量的地图自 ...

  8. SQLite 的创建与编辑

    创建数据库语句 -(void)creatData { sqlite3 *sqlite = nil; NSString *filePath = [NSHomeDirectory() stringByAp ...

  9. IOS数据存储之Sqlite数据库

    前言: 之前学习了数据存储的NSUserDefaults,归档和解档,沙盒文件存储,但是对于数据量比较大,需要频繁查询,删除,更新等操作的时候无论从效率上还是性能上,上述三种明显不能满足我们的日常开发 ...

随机推荐

  1. mysql 关联查询技巧

    废话不多说,直接进入正题 #数据准备 班级表class: CREATE TABLE `class` ( `class_no` ) unsigned zerofill NOT NULL AUTO_INC ...

  2. quartz定时任务实例

    一.spring注解方式 <!--<!–配置文件添加允许Spring注解–>--> <!--<task:annotation-driven scheduler=&q ...

  3. go里面的指针用法

    什么是指针 指针是存储一个变量的内存地址的变量. 在上图中,变量 b 的值是 156,存储在地址为 0x1040a124 的内存中.变量 a 存储了变量 b 的地址.现在可以说 a 指向 b. 指针的 ...

  4. Hibernate入门(十)inverse

    双向关联产生多余的SQL语句 /** * 添加一个订单到id为6的客户中 */ @Test public void fun1(){ Session session = HibernateUtils.g ...

  5. linux服务器重启指令

    一.Linux 的五个重启命令 1.shutdown 2.poweroff 3.init 4.reboot 5.halt 二.五个重启命令的具体说明 shutdown reboot 在linux下一些 ...

  6. java框架之spring

    一.HelloWorld程序 导入四个核心包(core.beans.expression.context)和一个logging的包: 写一个类并在 xml 中配置相应的bean(两个重要属性 id 和 ...

  7. css3 简易时钟

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. loj#2483. 「CEOI2017」Building Bridges(dp cdq 凸包)

    题意 题目链接 Sol \[f[i], f[j] + (h[i] - h[j])^2 + (w[i - 1] - w[j]))\] 然后直接套路斜率优化,发现\(k, x\)都不单调 写个cdq就过了 ...

  9. java调用matlab

    object result[]; result = pClass1.job_3in1(2, c, ws2, 1275, a, 0); string adg[]; adg = result[1].toS ...

  10. 我写的Java相关的文章

    此文正在更新中... Activiti 升级到Activiti7了. Web service/Soap Java如何调用.net写的asmx服务