注册 登录
编程论坛 Oracle论坛

[求助]oracle下怎么创建游标

xiaqin802 发布于 2006-05-31 14:16, 2425 次点击
可不可以给我例子看看,谢谢!!!!!!!1
4 回复
#2
zhoche20082006-06-12 22:21
--隐式游标
set serveroutput on;
begin
update emp set sal=sal+100 where empno=111;
if SQL%found then
dbms_output.put_line('编号7369的员工工资已更新');
else
dbms_output.put_line('编号7369的员工未找到');
end if;
end;
--显示游标
declare
vsal emp.sal%type;
cursor x is select sal from emp where deptno=20;
begin
open x;
loop
fetch x into vsal;
exit when x%notfound;
dbms_output.put_line(x%rowcount||' 部门编号为20的员工工资:'||vsal);
end loop;
close x;
end;
希望我发的这两个针对EMP表操作的游标示例对你有所帮助
#3
maozhibin9112006-06-20 18:57
very good ,,高手就是不一样,
#4
钱的马甲2006-06-21 18:06
还有游标参数呢,也请二楼说了吧。
#5
yms1232006-07-20 22:59

--补充REF游标
--显示游标
declare
vsal emp.sal%type;
type x is ref cursor;
xA x;
begin
open xA for 'select sal from emp where deptno=20';
loop
fetch xA into vsal;
exit when xA%notfound;
dbms_output.put_line(xA%rowcount||' 部门编号为20的员工工资:'||vsal);
end loop;
close xA;
end;

1