oracle 如何关闭游标
1个回答
展开全部
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;
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;
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询