Oracle-任何错误后如何停止脚本执行?

发布于 2025-01-26 11:08:38 字数 227 浏览 2 评论 0原文

例如,假设我们有以下在产品中执行的脚本。

drop index idx_test1;

drop index idx_test2;

但是,在执行第一个指令后,我们会得到错误:ora-00054:资源忙碌并使用NOTAIT指定或超时过期获取。我想停止所有后续说明。有什么方法可以在SQLPLUS和SQLDEVEVER/PL/SQL开发人员中进行操作?

For example, let's say we have the following script to execute in prod.

drop index idx_test1;

drop index idx_test2;

But, after execute first instruction we get the error: ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired. From here I'd like to stop all subsequent instructions. Is there any way to do it in sqlplus and sqldeveloper/PL/SQL Developer?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2025-02-02 11:08:38

我建议使用SQL*Plus运行脚本。您将使用

WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK 

此功能可以成为glogin.sql的一部分,也可以作为生产脚本的标题。

这还将将错误代码发送到您自己的日志记录的调用过程中,因此,如果您有一些编排者,则可以知道发生了什么。

I would recommend running scripts using Sql*Plus. You would use

WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK 

This can be part of your glogin.sql or just as a header of your production script.

This will also send the error code to the calling process for your own logging so if you have some orchestrator, it can know what's happened.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文