Page 1 of 1

Reporting error in Batch of a Shell Unix executing sql

Posted: Thu Nov 16, 2006 7:58 am
by m.amari
Hi to all.

I have to launch a shell unix (in a batch) who executes a .sql.
Sql file executes a stored procedure Oracle.

My problem is to return an error message in the batch if anythings goes wrong in the sql ( proc invalid, tables not founded...).

Thanks,
M.

Posted: Thu Nov 16, 2006 8:37 am
by chulett
You'll need to set the exit status of the script appropriately based on what happens inside your sqlplus session. And that will also depend on how your proc reports out problems. We do this by echoing all activity during the session into a tmp file and then grep'ing the file for Oracle errors. If any are found, set the exit status appropriately and the calling job will notice.

Posted: Thu Nov 16, 2006 9:20 am
by ray.wurlod
Welcome aboard. :D

You manage this by including appropriate logic and exit commands in your script. For example exit 0 on success, exit 1 on failure. You can even return specific codes from shell variables, for example exit $reasoncode