Cursors
You use a cursor to fetch rows returned by a query. You retrieve the rows into the cursor using a
query and then fetch the rows one at a time from the cursor. You typically use the following five
steps when using a cursor:
1. Declare variables to store the column values for a row.
2. Declare the cursor, which contains a query.
3. Open the cursor.
4. Fetch the rows from the cursor one at a time and store the column values in the variables
declared in Step 1. You would then do something with those variables, such as display
them on the screen, use them in a calculation, and so on.
5. Close the cursor.

1.T-SQL用法三(游标和Fetch) http://www.cnblogs.com/McJeremy/archive/2008/09/26/1299818.html

use pubs
go
--1,2 declare
declare @auid char(12),@aulname varchar(20),@aufname varchar(20), @st char(2),@auinfo varchar(50)
declare auth_cur cursor for
select au_id, au_lname, au_fname, state
from authors

--3.open
open auth_cur

--4.fetch
fetch next from auth_cur into @auid,@aulname,@aufname, @st
while (@@fetch_status=0)
begin
print '作者编号: '+@auid
print '作者姓名: '+@aulname+','+@aufname
print '所在州: '+@st
print '--------------------------'
fetch next from auth_cur into @auid,@aulname,@aufname, @st
end --5,6.close, deallocate
close auth_cur
deallocate auth_cur

  

sql:oracle, CURSOR的更多相关文章

  1. Oracle cursor学习笔记

    目录 一.oracle库缓存 1.1.库缓存简介 1.2.相关概念 1.3.库缓存结构 1.4.sql执行过程简介 二.oracle cursor 2.1.cursor分类 2.2.shared cu ...

  2. 常用SQL[ORACLE]

        1.常用系统函数 2.常用sql语句 3.一些定义和关键字 4.需要注意点   1.常用系统函数 ↑ --decode decode(column,if_value,value,elseif_ ...

  3. Oracle Cursor的使用

    When Oracle Database executes a SQL statement, it stores the result set and processing information i ...

  4. sql: Oracle simple example table

    --Oracle 9i 实例数据脚本地址:$oracle_home/rdbms/admin/utlsampl.sql CREATE TABLE DEPT (DEPTNO NUMBER(2) CONST ...

  5. 转 oracle cursor 游标

    转自:http://blog.csdn.net/liyong199012/article/details/8948952 游标的概念:     游标是SQL的一个内存工作区,由系统或用户以变量的形式定 ...

  6. SQL游标(cursor)详细说明及内部循环使用示例

    游标 游标(cursor)是系统为用户开设的一个数据缓冲区,存放SQL语句的执行结果.每个游标区都有一个名字,用户可以用SQL语句逐一从游标中获取记录,并赋给主变量,交由主语言进一步处理. 游标是处理 ...

  7. [PL/SQL]oracle数据库的导出导入

    一.PL/SQL Developer工具一般对oracle的导入导出有以下4中方式: 1.Oracle导出导入方式 这种方式导出导入为.dmp的文件格式,.dmp文件是二进制的,可以跨平台,还能包含权 ...

  8. [SQL]oracle 的to_char、to_number、to_date用法

    关键字: oracle 的to_char.to_number.to_date用法 TO_CHAR 是把日期或数字转换为字符串TO_DATE 是把字符串转换为数据库中得日期类型转换函数TO_NUMBER ...

  9. SQL SERVER CURSOR游标的使用(转载)

    一:认识游标 游标(Cursor)它使用户可逐行访问由SQL Server返回的结果集. 使用游标(cursor)的一个主要的原因就是把集合操作转换成单个记录处理方式. 用SQL语言从数据库中检索数据 ...

随机推荐

  1. poj 3176 Cow Bowling(区间dp)

    题目链接:http://poj.org/problem?id=3176 思路分析:基本的DP题目:将每个节点视为一个状态,记为B[i][j], 状态转移方程为 B[i][j] = A[i][j] + ...

  2. 复习知识点:TabBarViewController(微信框架)

    TabBarViewController:标签视图控制器 在application设置 创建四个视图控制器 引入视图控制器头文件 #import "AppDelegate.h" # ...

  3. CocoaPods的安装及设置

    1>CocoaPods简介 CocoaPods是一个用来帮助我们管理第三方依赖库的工具 在开发iOS应用时,会经常使用第三方类库,手动下载比较麻烦,通过CocoaPods可以便捷的下载与管理第三 ...

  4. WebLogic(12C)——Server

    上篇博客介绍了Weblogic的安装.Domain的创建,以及怎样进入管理控制台. WebLogic Server安装教程 1.Server(server)概念 2,创建Server(server) ...

  5. Java简单记录

    XML指令: <?xml version="1.0" encoding="UTF-8" standalone="no" ?> & ...

  6. RBAC - 基于角色的权限控制

    ThinkPHP中关于RBAC使用详解 自己的源码下载:百度网盘,thinkPHP文件夹下,RBAC文件夹. 重要的是,权限信息的写入函数等.在源码中能找到,Modules/Amin/Common/c ...

  7. Impossible WPF Part 2: Binding Expressions

    原文 http://www.11011.net/wpf-binding-expressions Back in April I posted an idea for building an expre ...

  8. springmvc+mybatis+redis(转)

    最近在学习redis的使用方法,它的本地使用方法比较简单,只需要先启动Redis服务器,然后运行测试代码即可.但是现在我想要在网站上访问数据库的时候采用Redis缓存,问题就出来了.要么是缓存直接失效 ...

  9. php MySQLi部分函数(面向对象和过程)

    版本支持:PHP > 5.0  MySQL > 4.0 2. mysqli 连接数据库: $db = new mysqli(host,user,password,database);返回一 ...

  10. grep egrep fgrep命令

    一.grep.egrep.fgrep命令 本文中主要介绍了linux系统下grep egrep fgrep命令和正则表达式的基本参数和使用格式.方法.(注释:文中fg代表例子,) 1.1.基本定义: ...