Hi I would like to embed a sql query in my shell script.
Also, before any the sql query is executed, i would like to validate username and password.
sqlplus -s $user/$passwrd <<ENDOFSQL
whenever sqlerror exit sql.sqlcode;
select sysdate from dual;
exit;
ENDOFSQL
RetCode=$?
#Check the return code from SQL Plus
if [ $RetCode != 0 ]
then
echo "********************"
echo "ERROR: The SQL Plus Command Failed. RetCode: $RetCode"
else
echo "********************"
echo "SQL Plus Successfully Ran. RetCode: $RetCode"
fi
If provided userid and password is not correct , then sql query will not execute and script will exit, so no need to validate userid and password here.