您的位置:首页 > 数据库

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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: