Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

How can I set the exit code of a script?

The following doesn't seem to work


     retCode number := 0;

     retCode := 30; 
EXIT :retCode ;

Gives the usage for EXIT with an exit code of 1

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.