title: WHENEVER SQLERROR never works
body: <p>I don't know what can be a reason and I spent already hours on the Web trying to figure out what's wrong in my case.
  I've checked <a href="https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12052.htm" rel="nofollow noreferrer">official documentation</a> and some <a href="http://tkyte.blogspot.com/2010/04/new-thing-about-sqlplus.html" rel="nofollow noreferrer">thought from Tom Kyte</a> on this and surely <a href="https://stackoverflow.com/questions/1402610/how-do-i-capture-a-sqlplus-exit-code-within-a-shell-script">topic on stackoverflow</a> about it.</p>
  
  <p>I use following code:</p>
  
  <pre><code>.. &lt; &lt;(sqlplus -s /nolog &lt;&lt;EOF
           set errorlogging on
           WHENEVER OSERROR EXIT FAILURE
           WHENEVER SQLERROR EXIT FAILURE
           connect ${use}/${pwd}@${database}
           @$SCRIPTS_PATH/script.sql
           EOF
            )
  
  echo Exited with $?
  </code></pre>
  
  <p>I've emulated different failure scenarios such as :</p>
  
  <ul>
  <li>used a wrong user name</li>
  <li>made syntax error in the sql squery</li>
  </ul>
  
  <p>But this guy all the time returns the same result:</p>
  
  <pre><code>Exited with 0
  </code></pre>
  
  <p>I've tried different ways, such as</p>
  
  <pre><code>WHENEVER SQLERROR EXIT SQL.SQLCODE
  WHENEVER SQLERROR EXIT FAILURE 
  </code></pre>
  
  <p>and so on but none of them worked.</p>
  
  <p>Most of the people on internet say that this works for them.
  So I'm getting confused here...</p>
  
  <p>Probably, this feature somehow related with the version of my SQL*Plus / Oracle /  shell / Unix. But I didn't encounter information about such restrictions.</p>
  
  <p>What am I missing here?</p>
  
  <p>If anybody can share any ideas I'll be very grateful.
  Thank you in advance.</p>