欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

oracle 如何关闭游标 close cursor 有大用

1. 用open打开的,用close关闭
declare
cursor mycursor is
select * from emp for update;
myrecord emp%rowtype;
begin
open mycursor;
loop
fetch mycursor into myrecord;
exit when mycursor%notfound;
if (myrecord.sal=2000) then
update emp
set sal=2001
where current of mycursor;
end if;
end loop;
close mycursor;
commit;
end;
2. 用for 循环的,循环完了就自己关了
declare
cursor mycursor is
select * from emp;
begin
for i in mycursor
loop
dbms_output.put_line(i.job);
end loop;
end;


来自 https://zhidao.baidu.com/question/1881777142190747708.html


普通分类: