begin
DML语句1;
DML语句2;
...
DML语句n;
commit;
end;
/
通过测试,假设DML语句n出现异常,那么DML语句1...n-1所做的操作将会rollback;
其实以上PL/SQL语句块等价于(参考
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:43818437682131):
begin
savepoint xx;
DML语句1;
DML语句2;
...
DML语句n;
commit;
exception
when others then
rollback to xx;
raise;
end;
/
那么如何实现即便DML语句n出现异常,DML语句1...n-1所做的操作依然能够commit呢???;
方法一:
begin
begin
DML语句1;
exception
when others then
null;
end;
begin
DML语句2;
exception
when others then
null;
end;
...
begin
DML语句n;
exception
when others then
null;
end;
commit;
end;
/
方法二:
begin
DML语句1;
DML语句2;
...
DML语句n;
commit;
exception
when others then
commit;
end;
/
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26156924/viewspace-767509/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26156924/viewspace-767509/