declare
begin
for i in 1..10 loop
begin
if i=5 then
insert into mas values(i,'mas');
else
insert into mas values(i,i);
end if;
exception when others then
dbms_output.put_line('exception');
--raise_application_error(-20001,'test');
end;
end loop;
exception when others then
dbms_output.put_line('exception');
end;
begin
for i in 1..10 loop
begin
if i=5 then
insert into mas values(i,'mas');
else
insert into mas values(i,i);
end if;
exception when others then
dbms_output.put_line('exception');
--raise_application_error(-20001,'test');
end;
end loop;
exception when others then
dbms_output.put_line('exception');
end;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30201626/viewspace-1813633/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30201626/viewspace-1813633/
本文介绍了一段使用PL/SQL进行的SQL操作案例,包括动态插入数据和异常处理机制。通过实例演示了如何在循环中根据条件插入不同数据到表格中,并在出现异常时进行错误输出。
1009

被折叠的 条评论
为什么被折叠?



