Error Handling in Korn Shell scripts

Hi,

I am using few ISQL statements to update and delete from a few tables in sybase, now i want to roll back the transaction when any of the statements fail.How i can i capture these errors in the shell scripts.Please advise.

Thanks,
Gopi

catch the errorlevel of the command:

[code]
...
/path/to/somecommand ; RC=$?
if [ $RC -eq 0 ] ; then
print - "everything worked out fine"
else
print - "something screwed up"
fi

[code]

The errorlevel is set anew for every command issued, so be sure to get it as soon as the program in question is finished.

bakunin

I agree its only a print.. but it is against point 1 of this post ?

Bakunin - please refrain from profanity. Thanks. (Edited both post and changed the offending word)

Checking the return code won't help. What bhgopi wants to do is rollback the transaction within Sybase. By the time you get the Unix return code the transaction is already committed.

Bottom line: You have to check the results and do the rollback or commit entirely from within isql. You probably should be asking this question on a Sybase forum, rather than Unix.