oracle 游标循环插入数据
这样写可以么,有什么问题呢 ,听说一个脚本里面最好只有一个 begin end块要好些,该怎么改
declare
cursor emp_cur is select * from emp;
emp_record varchar2(10);
begin
open emp_cur;
loop
fetch emp_cur into emp_record ;
exit when emp_cur%notfound;
for i in (select a from b where c=emp_record)
loop
begin
insert into c(m) values(a);
if mod(i,10000)=0 then --1万提交一次
commit;
end if;
exception
when others then
null;
commit;
end;
end loop;
end loop;
close emp_cur;
end;