title: Detect sqlplus error in dos batch script?
body: <p>We have the following batch script:</p>
  
  <pre><code>(
  echo @release.sql
  echo exit
  ) | sqlplus x/y@orcl
  
  if %errorlevel% gtr 1 goto dberror
  </code></pre>
  
  <p>Issue is - the statement <code>if %errorlevel% gtr 1</code> never appears to be true when there is a sql error.</p>
  
  <p>If we put garbage commands in the release.sql file, sqlplus does complain:</p>
  
  <pre><code>SQL&gt; SP2-0042: unknown command "blah" - rest of line ignored.
  SQL&gt; Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
  </code></pre>
  
  <p>But <code>%errorlevel%</code> still equals 0.  How can we determine that there was a sql error?</p>
  
  <hr>
  
  <p><strong>Update</strong>: This code DOES appear to work for some sql errors.  It will work if I do <code>drop table blah</code> but it won't work with just the command <code>blah</code></p>