Oracle中存储过程的问题???

m540920181 2011-10-11 02:14:51
create or replace procedure myproc_3
as
cursor mysor is select * from emp for update;
begin
open mysor;
for i in mysor
loop
if i.deptno = 10 then
update emp set sal=(sal+500)* 3 where current of mysor;
elsif i.deptno = 20 then
update emp set sal=sal* 3 where current of mysor;
else
update emp set sal=sal-1000 where current of mysor;
end if ;
end loop;
close mysor;
end;

select * from emp;
begin
myproc_3;
end;

存储过程是成功 的,为什么运行的时候系统报错是,游标已经打开
...全文
71 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
独孤名 2011-10-11
  • 打赏
  • 举报
回复
同意2L的说法!
night_vincent 2011-10-11
  • 打赏
  • 举报
回复
用for 就不需要open/close游标了
还有 你忘记在代码里加commit了
thinoft 2011-10-11
  • 打赏
  • 举报
回复
关闭后还要再释放游标 deallocate mysor

1,618

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧