oracle – Sql * plus总是返回退出代码0?

oracle – Sql * plus总是返回退出代码0?,第1张

概述每当我使用Sql * plus运行sql脚本并检查$?,即使脚本不成功,也会得到0. 例 #$sqlplus user/password@instance @script.sqlSQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 7 14:20:44 2013Copyright (c) 1982, 2005, Oracle. All 每当我使用sql * plus运行sql脚本并检查$?,即使脚本不成功,也会得到0.

例@H_502_2@

#$sqlplus user/password@instance @script.sqlsql*Plus: Release 10.2.0.1.0 - Production on Wed Aug 7 14:20:44 2013copyright (c) 1982,2005,Oracle.  All rights reserved.Connected to:Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit ProductionWith the Partitioning,olAP and Oracle Data Mining optionsJserver Release 9.2.0.8.0 - Production     v$dataf-ile d,*ERROR at line 6:ORA-00933: sql command not properly endeddisconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit ProductionWith the Partitioning,olAP and Oracle Data Mining optionsJserver Release 9.2.0.8.0 - Production$echo $?0$

我希望在发生错误时返回非零值.@H_502_2@

我该如何实现呢?@H_502_2@ 你必须明确地告诉sqlplus在你的脚本中这样做.基本上可以使用两个语句:

> WHENEVER sqlERROR EXIT sql.sqlCODE
> WHENEVER OSERROR EXIT@H_502_2@

例如:@H_502_2@

WHENEVER sqlERROR EXIT sql.sqlCODEbegin  SELECT ColUMN_DOES_NOT_EXIST FROM DUAL;END;/

并且对于 *** 作系统错误:@H_502_2@

WHENEVER OSERROR EXIT FAILURESTART no_such_file

有关更多信息,请参阅this和that.@H_502_2@

希望它有帮助.祝你好运!@H_502_2@ 总结

以上是内存溢出为你收集整理的oracle – Sql * plus总是返回退出代码0?全部内容,希望文章能够帮你解决oracle – Sql * plus总是返回退出代码0?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1167534.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-01
下一篇 2022-06-01

发表评论

登录后才能评论

评论列表(0条)

保存