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语言从数据库中检索数据 ...
随机推荐
- 警告:‘xxxx’ 将随后被初始化
关于编译报警告.本次是接手一个新手的代码,总共不到1K行的代码.两个类.编译的时候报的警告,本来也不打算管理这个事情的.要求也不会有那么严格.但上午看完代码后,觉得毕竟是新手写的代码,还是有很多需要修 ...
- JavaScript螺纹的问题和答案
要求: JavaScript是单线程的,有任务队列.比方使用setTimeou(func,secs)来在secs毫秒后向任务队列加入func.可是,setTimeout后面跟一个死循环,那么死循环导致 ...
- javascript实现贪吃蛇
<html> <head> <style> body { background:#444; } .rect { border:1px solid #94F; wid ...
- MCU开发之I2C通信
程序状态字PSW是8位寄存器,用于存放程序运行的状态信息,PSW中各位状态通常是在指令执行的过程中自动形成的,但也可以由用户根据需要采用传送指令加以改变.各个标志位的意义如下: PSW.7(Cy):进 ...
- IPv6-only 的兼容性解决方案
前几天Apple宣布 6月1日后所有应用必须支持IPv6-only网络 今天抽空看了下这方面的知识 首先解释下IPv6的是什么? 维基百科的定义如下:IPv6是Internet Protocol ve ...
- ThinkPHP文件上传类
TP框架自带文件上传类使用: 类文件在ThinkPHP/Library/Think/默认在目录下 public function upload(){ $upload = new \Think\Uplo ...
- Windows Phone 8初学者开发—第15部分:在选中ListItem时播放声音
原文 Windows Phone 8初学者开发—第15部分:在选中ListItem时播放声音 第15部分:在选中ListItem时播放声音 原文地址: http://channel9.msdn.co ...
- 基于visual Studio2013解决C语言竞赛题之0510求最大和
题目
- CMake初步(2)
转自:<你所不知的OSG>第一章:CMake初步(2) http://bbs.osgchina.org/forum.php?mod=viewthread&tid=1229& ...
- 什么是C# Lambda表达式?形如:p=>p.abc
这里介绍C# Lambda表达式,它实际上和匿名方法没有什么不同.Lambda的输入参数就对应着delegate括号里面的参数,由于C# Lambda表达式可以推断参数的类型,所以这里的参数无需声明. ...