Sunday, February 19, 2012

Capture errors from "isql"

Hi,

Just wanted to know if there is anyway I can capture errors generated in the SQL batch passed into isql with the "-i" option.

ie

If there is an sql batch store in file say test.sql and I pass it as input to isql as

isql -Uxxxx -itest.sql -Pyyyy

is there anyway I can figure out (outside the isql using error valriables like $status in UNIX C-shell or ERRORLEVEL in DOS) if all the SQLs in that script file (test.sql) has executed successfully or notRE:
Hi, Just wanted to know if there is anyway I can capture errors generated in the SQL batch passed into isql with the "-i" option. ie If there is an sql batch store in file say test.sql and I pass it as input to isql as isql -Uxxxx -itest.sql -Pyyyy

Q1 Is there ANY way I can figure out (outside the isql using error valriables like $status in UNIX C-shell or ERRORLEVEL in DOS) if all the SQL in that script file (test.sql) has executed successfully or not?

This may not be the desired answer, however the question asked about (ANY) way.

A1 Yes.

One approach would require some development; assuming each stored procedure or a batch is designed to return meaningful "result codes"; one could programatically parse the resulting output file to examine each "result code" in the output file e.g.(osql -Uxxxx -itest.sql -Pyyyy -oOutPutFile.out).|||I tried the "-b" option and that worked too. The %ERRORLEVEL% was able to have a non-0 value in case of errors.

No comments:

Post a Comment