The Oracle (tm) Users' Co-Operative FAQ
How do I get the return code (or exit code) from SQL*Plus to a UNIX variable ?
Author's name: David T. Bath Author's Email: David.Bath@edipost.auspost.com.au Also once known as dtb@otto.bf.rmit.edu.au or orafaq@bf.rmit.edu.au |
Date written: 9th Aug 2001 Oracle version(s): 8.1.7 |
How do I get the return code (or exit code) from SQL*Plus to a UNIX variable ? |
Yes and No.
In sh variants, the exit code is available through $?
While SQL*Plus ATTEMPTs to put the Oracle error number into this value, this usually gets mod-ded by 256 or some such power of two, depending on your Unix dialect. A return of zero therefore means:....
a) It was really zero, and everything OK b) ORA-256, ORA-512, .... or something like that was the problem.复制
The real solution is to trap the textual output of the error through stderr, slurp and mangle it and then backtick the results into a variable. This may even be better, as you get the facility, which MIGHT be ORA, but might be something else entirely such as NET.
Further reading: N/A
最后修改时间:2020-04-16 15:13:16
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
【纯干货】Oracle 19C RU 19.27 发布,如何快速升级和安装?
Lucifer三思而后行
671次阅读
2025-04-18 14:18:38
Oracle RAC 一键安装翻车?手把手教你如何排错!
Lucifer三思而后行
630次阅读
2025-04-15 17:24:06
Oracle数据库一键巡检并生成HTML结果,免费脚本速来下载!
陈举超
539次阅读
2025-04-20 10:07:02
【活动】分享你的压箱底干货文档,三篇解锁进阶奖励!
墨天轮编辑部
488次阅读
2025-04-17 17:02:24
【ORACLE】记录一些ORACLE的merge into语句的BUG
DarkAthena
482次阅读
2025-04-22 00:20:37
一页概览:Oracle GoldenGate
甲骨文云技术
464次阅读
2025-04-30 12:17:56
【ORACLE】你以为的真的是你以为的么?--ORA-38104: Columns referenced in the ON Clause cannot be updated
DarkAthena
457次阅读
2025-04-22 00:13:51
火焰图--分析复杂SQL执行计划的利器
听见风的声音
412次阅读
2025-04-17 09:30:30
3月“墨力原创作者计划”获奖名单公布
墨天轮编辑部
371次阅读
2025-04-15 14:48:05
OR+DBLINK的关联SQL优化思路
布衣
350次阅读
2025-05-05 19:28:36