Search code examples
databaseunixstored-proceduressybasebatch-processing

Sybase stored proc called from isql on AIX: how to handle return code


I've got an AIX batch job that uses isql to execute a stored procedure in Sybase. The stored procedure is returning an error code under certain conditions. I would like for isql to pass that return code to the AIX script.

Can I capture the the stored proc's return code within isql, or do I have to write an output file of some kind and have my AIX script check that?

Here's what the isql command looks like. It's running inside a Korn shell script.

isql -D$database -S$server -U$userId -P$password << EOF
EXEC MY_STORED_PROC $AN_INPUT_PARAMETER
go
EOF

Solution

  • If I remember correctly, the $? is set to the command return value. Add something like this after the EOF line:

    
    if [[ $? != 0 ]]; then
        print "stored procedure failed"
        exit
    fi