sql:oracle, CURSOR
2015-11-24 16:56
447 查看
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) /article/5214927.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
相关文章推荐
- Oracle logminer使用方法总结
- Oracle 11g R2+RAC+ASM+OracleLinux6.4安装详解(图)
- Oracle-主键约束、唯一约束与外键约束
- Oracle备份与恢复介绍(物理备份与逻辑备份)
- Oracle中的锁概述
- oracle 添加表分区
- oracle blog
- oracle数据字典详解
- oracle启动和关闭数据库
- Oracle 统计信息(备份/导入)表分析-[注意要刷缓存]
- oracle 10g中的几个概念(表空间,数据库名,实例名,操作系统环境变量SID)
- Oracle位图索引与B-Tree索引的优缺点
- ORACLE中的SQL%ROWCOUNT
- Oracle sqlldr
- Oracle将字符串转换为数字,并替换特殊字符
- Oracle中GOTO的用法
- Linux平台Oracle多个实例启动
- Oracle Enterprise Manager
- linux配置oracle客户端,sqlplus、sqlldr、exp、imp
- oracle删除除空白以外的表数据