加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle – 有没有办法在出错时回滚并退出psql脚本?

发布时间:2020-12-12 16:26:23 所属栏目:百科 来源:网络整理
导读:我有一个psql脚本,如下所示: -- first set of statementsbeginsql statement;sql statement;sql statement;exception when others then rollback write some output (here I want to exit the entire script and not continue on to the next set of statem
我有一个psql脚本,如下所示:
-- first set of statements
begin
sql statement;
sql statement;
sql statement;
exception
    when others then
    rollback
    write some output
    (here I want to exit the entire script and not continue on to the next set of statements)
end
/
-- another set of statements
begin
sql statement;
sql statement;
sql statement;
exception
    when others then
    rollback
    write some output
    (here I want to exit the entire script and not continue)
end
/
... and so on

是否可以退出脚本并停止处理脚本的其余部分?

将以下行放在文件的顶部:
WHENEVER OSERROR EXIT ROLLBACK
WHENEVER SQLERROR EXIT ROLLBACK

……并确保你有一个升起;在异常处理程序的末尾.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读