patternMinor
sqlplus Setting the exit code of a script
Viewed 0 times
scripttheexitsettingcodesqlplus
Problem
How can I set the exit code of a script?
The following doesn't seem to work
Gives the usage for EXIT with an exit code of 1
The following doesn't seem to work
WHENEVER SQLERROR EXIT 5
DECLARE
retCode number := 0;
BEGIN
retCode := 30;
END;
/
EXIT :retCode ;Gives the usage for EXIT with an exit code of 1
Solution
Try it like this:
(See http://www.orafaq.com/forum/mv/msg/80574/233106/0/#msg_233106)
Bottom line is that retCode must be a variable defined in SQLPLUS's scope. Your DECLARE is inside a code block, and SQLPLUS can't see into it.
var retCode number
exec :retCode := 30;
exit :retCode(See http://www.orafaq.com/forum/mv/msg/80574/233106/0/#msg_233106)
Bottom line is that retCode must be a variable defined in SQLPLUS's scope. Your DECLARE is inside a code block, and SQLPLUS can't see into it.
Code Snippets
var retCode number
exec :retCode := 30;
exit :retCodeContext
StackExchange Database Administrators Q#3288, answer score: 5
Revisions (0)
No revisions yet.