I'm trying to return a sqlplus output to a shell script. This may sound simple enough but I've searched online for some time and cannot get my script to work.
Here is my pl/sql script:
SET SERVEROUTPUT ON
DECLARE
X_RETURN_MSG VARCHAR2(32767);
X_RETURN_CODE NUMBER;
BEGIN
X_RETURN_MSG := NULL;
X_RETURN_CODE := 5;
COMMIT;
END;
EXIT X_RETURN_CODE;
Here is my shell script:
sqlplus -s user/pwd <<EOF
@../sql/tester.sql
EOF
RETVAL=$?
echo $RETVAL
$RETVAL always returns 0 even when I have X_RETURN_CODE := 5