【发布时间】:2012-01-04 06:46:18
【问题描述】:
想知道当检测到SQL异常(其他时异常)时是否需要回滚:
declare
cursor c_test is
select *
from tesing;
begin
for rec in c_test loop
begin
update test1 set test1.name=rec.name where test1.id=rec.id;
IF sql%rowcount = 1 THEN
commit;
ELSIF sql%rowcount =0 THEN
dbms_output.put_line('No Rows Updated');
else
dbms_output.put_line('More than 1 row exists');
rollback;
END IF;
exception when others then
dbms_output.put_line(Exception');
rollback;
end;
end;
【问题讨论】:
-
我会在 Oracle 的 Implicit Rollbacks 上阅读 Tom Kyte。 SQL*Plus 是另一种动物,您可以明确告诉它自动提交任何一组语句。
标签: sql oracle exception-handling plsql