dps*_*ree 6 sql oracle transactions
我试图第一次在Oracle SQL中使用事务功能,似乎无法找到一个好的解释.我知道开始一个新会话将开始一个新的交易.我也理解提交/回滚用于结束它.我想要做的是执行两个语句,如果我们中的任何一个失败,撤消他们可能做出的任何更改并继续执行.如何检查此情况并相应地发出提交或回滚?
Obi*_*obi 16
使用PL/SQL块并编写如下内容:
begin
statement_zero;
savepoint my_savepoint;
begin
-- if either of these fail, then exception section will be executed
statement_one;
statement_two;
exception
when others then
rollback to my_savepoint;
end;
statement_three;
commit;
end;
Run Code Online (Sandbox Code Playgroud)
另见http://www.adp-gmbh.ch/ora/concepts/transaction.html