title: Managing error handling while running sqlplus from shell scripts
body: <pre><code>#!/bin/sh
  
  echo "Please enter evaluate database username"
  read eval_user
  echo "Please enter evaluate database password"
  read eval_pass
  echo "Please enter the database name"
  read db_name
  
  LOGFILE=shell_log.txt
  
  $ORACLE_HOME/bin/sqlplus -s /nolog &lt;&lt;-EOF&gt;&gt; ${LOGFILE}
  connect $eval_user/$eval_pass@$db_name
  WHENEVER OSERROR EXIT 9;
  WHENEVER SQLERROR EXIT SQL.SQLCODE;
  DBMS_OUTPUT.put_line('Connected to db');
  EOF
  
  if [ $? != 0 ]
  then 
  echo "The upgrade script failed. Please refer to the log results.txt for more information"
  echo "Error code $?"
  exit 0;
  fi
  </code></pre>
  
  <p>I am entering garbage values trying to force this script to fail. But, annoyingly, it keeps moving ahead without any mention of any error code. What else needs to be done here?</p>