Handling the ORA Error in the Unix Shell Script


I am trying to execute a script which actually runs a SQL and returns the value , write to to a CSV file and send it.

/data/oracle/product/ -s user_name/[email protected] @/export/home/script/abc.sql

I want to capture the error whenever there is any error while running the SQL part but it always hangs.

I tried putting "(($?)) && ((ERRORS += 1))" after above statement but it never reaches to that line.

I want to capture the error code in a variable ERROR and exit with the error code.

Kindly help

you can put it under TRY-Catch block. refer this manual