5

How can I set the exit code of a script?

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

asked Jun 13, 2011 at 13:35

1 Answer 1

5

Try it like this:

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 SQL*PLUS's scope. Your DECLARE is inside a code block, and SQL*PLUS can't see into it.

answered Jun 13, 2011 at 17:36

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.