title: How to capture exit code when using open/print to execute a SQL statement?
body: <p>I am using open/print to execute a SQL statement using sqlplus, like this:</p>
  
  <pre><code>open (PLSQL, "|sqlplus -s $db_url");
  print PLSQL &lt;&lt;ENDSQL;
  ... some SQL statements ...
  exit;
  ENDSQL
  close(PLSQL);
  </code></pre>
  
  <p>My question is how to capture the exit code of executing the sql statement if it runs into some errors. I think using DBI should be much better, but I prefer to have a solution to the problem above. Thanks a lot!</p>