0
votes

My nant script to execute sqlplus.exe looks like following

exec program="sqlplus.bat" basedir="${base.dir}" workingdir="${base.dir}" output="log.txt" failonerror="false" resultproperty="execresult"

arg line="${app.sqlplus} ${db.username} ${db.password} ${db.schema} ${var.exec.file} ${db.username} ${db.password}"

end exec

SqlPlus.bat has following contents

echo exit | %1 %2/%3@%4 @%5 %6 %7

I would ideally want to check the "execresult" which is the error code from exec command and show the respective message.

I have tried using the following statement in my SQL file but it did not help.

WHENEVER SQLERROR EXIT SQL.SQLCODE

Could you please point out the problem and possible solution ?

1

1 Answers

1
votes

Easiest answer is to remove the output and failonerror on your exec task because then NAnt will naturally show the message as it fails the build. I'm guessing you've avoided that because you want to handle some non-zero exit codes as warnings or success because you want to handle some non-zero exit codes as warnings or success. In that case:

<loadfile file="log.txt" property="execoutput" />
<fail if="${int::parse(execresult)>8" message="${execoutput}" />