title: ANT sql task: How to run SQL and PL/SQL and notice execution failure?
body: <p>to execute an .sql script file from ANT it works fine using the following task:</p>
  
  <pre><code>&lt;sql
      classpath="${oracle.jar}" driver="oracle.jdbc.OracleDriver"
      url="jdbc:oracle:thin:@@@{db.hostname}:@{db.port}:@{db.sid}" 
      userid="@{db.user}" 
      password="@{db.password}"
      src="@{db.sql.script}" /&gt;
  </code></pre>
  
  <p>But if the .sql file not only contains pure SQL but also PL/SQL the task will fail. This could be solved by using the following snippet:</p>
  
  <pre><code>&lt;sql
      classpath="${oracle.jar}" driver="oracle.jdbc.OracleDriver"
      url="jdbc:oracle:thin:@@@{db.hostname}:@{db.port}:@{db.sid}" 
      userid="@{db.user}" 
      password="@{db.password}"
      delimiter="/"
      delimitertype="row"
      src="@{db.sql.script}" /&gt;
  </code></pre>
  
  <p>But if my script contains both SQL <strong>and</strong> PL/SQL then neither ANT task will work. Another solution would be to use the "exec" task with "sqlplus":</p>
  
  <pre><code>&lt;exec executable="sqlplus" failonerror="true" errorproperty="exit.status"&gt;
      &lt;arg value="${db.user}/${db.password}@${db.hostname}:${db.port}/${db.sid}"/&gt;
      &lt;arg value="@${db.sql.script}"/&gt;
  &lt;/exec&gt;
  </code></pre>
  
  <p>But unfortunately this task will never fail, hence the build returns always with "SUCCESSFUL" even though the sql script execution failed. The error property which I tried to set would not return any error code.</p>
  
  <p>Any ideas/suggestions how to solve this problem?</p>
  
  <p>Thanks,</p>
  
  <p>Peter</p>