sql:oracle, CURSOR
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的更多相关文章
- Oracle cursor学习笔记
目录 一.oracle库缓存 1.1.库缓存简介 1.2.相关概念 1.3.库缓存结构 1.4.sql执行过程简介 二.oracle cursor 2.1.cursor分类 2.2.shared cu ...
- 常用SQL[ORACLE]
1.常用系统函数 2.常用sql语句 3.一些定义和关键字 4.需要注意点 1.常用系统函数 ↑ --decode decode(column,if_value,value,elseif_ ...
- Oracle Cursor的使用
When Oracle Database executes a SQL statement, it stores the result set and processing information i ...
- sql: Oracle simple example table
--Oracle 9i 实例数据脚本地址:$oracle_home/rdbms/admin/utlsampl.sql CREATE TABLE DEPT (DEPTNO NUMBER(2) CONST ...
- 转 oracle cursor 游标
转自:http://blog.csdn.net/liyong199012/article/details/8948952 游标的概念: 游标是SQL的一个内存工作区,由系统或用户以变量的形式定 ...
- SQL游标(cursor)详细说明及内部循环使用示例
游标 游标(cursor)是系统为用户开设的一个数据缓冲区,存放SQL语句的执行结果.每个游标区都有一个名字,用户可以用SQL语句逐一从游标中获取记录,并赋给主变量,交由主语言进一步处理. 游标是处理 ...
- [PL/SQL]oracle数据库的导出导入
一.PL/SQL Developer工具一般对oracle的导入导出有以下4中方式: 1.Oracle导出导入方式 这种方式导出导入为.dmp的文件格式,.dmp文件是二进制的,可以跨平台,还能包含权 ...
- [SQL]oracle 的to_char、to_number、to_date用法
关键字: oracle 的to_char.to_number.to_date用法 TO_CHAR 是把日期或数字转换为字符串TO_DATE 是把字符串转换为数据库中得日期类型转换函数TO_NUMBER ...
- SQL SERVER CURSOR游标的使用(转载)
一:认识游标 游标(Cursor)它使用户可逐行访问由SQL Server返回的结果集. 使用游标(cursor)的一个主要的原因就是把集合操作转换成单个记录处理方式. 用SQL语言从数据库中检索数据 ...
随机推荐
- Runtime.getRuntime().exec中命令含有括号问题
在写批量运行bat工具的时候.想起了之前写的定时小工具里面的运行方法. 使用Runtime.getRuntime().exec方法. Runtime.getRuntime().exec("c ...
- 技术贴:解码时AVC1和H264的差别
我一直疑问为什么有些视频解码时显示格式是:H264,大部分又是:AVC1 我在搜索编程资料时在微软的msdn上发现的: 原文:http://msdn.microsoft.com/en-us/libra ...
- 什么是CALayer
一.什么是CALayer * 在iOS系统中,你能看得见摸得着的东西基本上都是UIView,比如一个按钮.一个文本标签.一个文本输入框.一个图标等等,这些都是UIView. * 其实UIView之所以 ...
- 怎样让jQuery和其它js库共存
怎样让jQuery和其它js库共存 有时候需要同时使用jQuery和其它javascript,比如在joomla中默认的是motools,但很多人还是希 望能够使用jQuery,如果直接调用的话,由于 ...
- Python 函数基础、有序集合、文件操作(三)
一.set 特点: set是一个无序且不重复的元素集合访问速度快:天生解决元素重复问题 方法: 初始化 >>> s1 = set()>>> print(type(s ...
- CodeForces 189A 166E 【DP ·水】
非常感谢 Potaty 大大的援助使得我最后A出了这两题DP ================================== 189A : 求切分后的ribbon最多的数目,不过要求切分后只能存 ...
- 有什么很好的软件是用 Qt 编写的?
作者:尘中远链接:http://www.zhihu.com/question/19630324/answer/19365369来源:知乎 一些出名的例子如下:(wiki搬运) 3DSlicer, a ...
- Uniconnection 连 mysql 有时会断线的
你定义localfailover:=ture.断线后会自己接上 firedac没这种功能.只有unidac有
- [置顶] Android4.x对长按电源键(挂断键)和短按电源键(挂断键)的详细处理流程
1. 简介 Android4.x在Framework的PhoneWindowManager对Power(KeyEvent.KEYCODE_POWER)和Home(KeyEvent.KEYCODE_HO ...
- CUSPARSE 第三章 CUSPARAE索引和数据格式
(纯属自学笔记,部分翻译,不会翻译的不翻译) 3.1 索引基本格式 该函数库支持 zero- and one-based 索引. The index base 是通过 cusparseIndexBas ...