sqlplus 设置脚本的退出代码

Sco*_*ott 5 sqlplus

如何设置脚本的退出代码?

以下似乎不起作用

WHENEVER SQLERROR EXIT 5

DECLARE
     retCode number := 0;

BEGIN
     retCode := 30; 
END;
/
EXIT :retCode ;
Run Code Online (Sandbox Code Playgroud)

给出退出代码为 1 的 EXIT 的用法

Ker*_*tts 5

像这样尝试:

var retCode number
exec :retCode := 30;
exit :retCode
Run Code Online (Sandbox Code Playgroud)

(见http://www.orafaq.com/forum/mv/msg/80574/233106/0/#msg_233106

底线是retCode必须是在 SQL*PLUS 范围内定义的变量。您的DECLARE位于代码块内,SQL*PLUS 无法查看它。