PLSQL_游标变量
2011-02-28 23:28
197 查看
declare
--声明一个游标类型
type mycur is ref cursor;
--声明一个游标变量,将类型实例化
cur mycur;
v_name emp.ename%type;
v_job emp.job%type;
begin
select job into v_job from emp where empno='111';
if v_job = 'saler' then
--为游标指定一个结果集
open cur for select ename from emp where sal<3000;
else
--为游标指定一个结果集
open cur for select ename from emp where sal>3000;
end if;
--提取
while cur%found loop
dbms_output.put_line(v_name);
fetchcur into v_name;
end loop;
--关闭
close cur;
exception
when others then
dbms_output.put_line(sqlcode||sqlerrm);
end;
--声明一个游标类型
type mycur is ref cursor;
--声明一个游标变量,将类型实例化
cur mycur;
v_name emp.ename%type;
v_job emp.job%type;
begin
select job into v_job from emp where empno='111';
if v_job = 'saler' then
--为游标指定一个结果集
open cur for select ename from emp where sal<3000;
else
--为游标指定一个结果集
open cur for select ename from emp where sal>3000;
end if;
--提取
while cur%found loop
dbms_output.put_line(v_name);
fetchcur into v_name;
end loop;
--关闭
close cur;
exception
when others then
dbms_output.put_line(sqlcode||sqlerrm);
end;
相关文章推荐
- 【PLSQL】变量声明,结构语句,cursor游标
- plsql: 动态sql && 游标变量
- 游标变量用法经典
- PLSQL之循环和游标
- 美丽Oracle第五天 PLSQL编程、游标、异常
- Oracle PLSQL Demo - 13.游标的各种属性[Found NotFound ISOpen RowCount CURSOR]
- PL/SQL 游标变量
- 29.PLSQL中的参考游标
- PLSQL条件语句完成员工加薪功能(记录类型+游标case when+if+for update+where current of)
- 简单的plsql to tsql ,游标拆解
- 说明定义游标cursor时的select语句里可以用变量
- 游标常量+游标变量的使用
- PLSQL_标准游标类型的解析(概念)
- plsql 开发手记 游标,动态sql ,自定义集合
- 游标变量操作
- 在PL/SQL中使用游标、动态sql和绑定变量的小例子
- SqlServer 临时表、表变量、函数 替代游标
- plsql中游标使用
- plsql游标、循环排错
- TSQL 带参数的游标 表值类型+record + cursor 模仿 plsql %rowtype