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. Hibernate入门(十二)离线条件检索

    Hibernate——离线条件检索DetachedCriteria DetachedCriteria翻译为离线条件查询,因为它是可以脱离Session来使用的一种条件查询对象,我们都知道Criteri ...

  2. Hibernate入门(九)级联删除

    Hibernate级联删除 上一篇文章学习了级联保存和更新,这个级联删除应该很好理解的.一样的道理,删除一方,同时删除有关联的一方. https://www.cnblogs.com/deepSleep ...

  3. 浅谈spring中AOP以及spring中AOP的注解方式

    AOP(Aspect Oriented Programming):AOP的专业术语是"面向切面编程" 什么是面向切面编程,我的理解就是:在不修改源代码的情况下增强功能.好了,下面在 ...

  4. js节点的类型

    1. dom>documentElement>body>tagname 2.我们常用的节点标签. 元素节点(标签) 文本节点 属性节点(标签里的属性) 3.document有个属性n ...

  5. C#设计模式之九组合模式(Composite Pattern)【结构型】

    一.引言 今天我们要讲[结构型]设计模式的第四个模式,该模式是[组合模式],英文名称是:Composite Pattern.当我们谈到这个模式的时候,有一个物件和这个模式很像,也符合这个模式要表达的意 ...

  6. 异常: Bean named 'org.springframework.transaction.interceptor.TransactionInterceptor#0' is expected to be of type 'org.aopalliance.aop.Advice' but was actually of type 'org.springframework.transaction.i

    场景: 在使用spring整合hibernate事务时报错解决: spring-aop中已经包含aopaliance,删除多余的jar包

  7. Retrofit2 原理解析

    Retrofit是什么 官网介绍是A type-safe HTTP client for Android and Java,是一个 RESTful 的 HTTP 网络请求框架的封装,但网络请求不是Re ...

  8. crontab清理日志

    1.日志介绍 2.日志清理  (以下达到清理效果) du -sh * //查看日志大小 * 1 * * * cat /dev/null > /var/log/message 解释/dev/nul ...

  9. canvas-8searchLight4.html

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

  10. element vue validate验证名称重复 输入框与后台重复验证 特殊字符 字符长度 及注意事项

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