I have a script which calls SQLPLUS and passes the login information. It is working great, but if the database is down or if it passes a bad parameter, the connect does not work, but I still get a return code of zero. Is there a way to capture when there is a connect error and exit with a return code?
This is what i have now:
But I get these messages:
This is what i have now:
Code:
set WHENEVER SQLERROR exit 1
set WHENEVER OSERROR exit 1
set serveroutput on size 100000
sqlplus /nolog <<EOF
connect $USERNAME/$PASSWORD@$1
select * from table1;
exit
EOF
if [ $? != 0 ]
then
echo "NOT CONNECTED TO SQL"
exit 1
fi
echo "Return Code = $?"
But I get these messages:
Code:
SQL> ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
SQL> SQL> Return Code = 0