Search code examples
unixkshsap-iqisqlsybase-asa

To Capture the Error in Sybase IQ SQL Execution using dbisqlc inside ksh shell Script


I have a shell script as below through which I'm connecting Sybase IQ through dbisqlc.

I would like to capture if there Error is any Error occurs during the Script Execution. I coded like below. But eventhough if there is any failure in SQL Execution , the Return Count in always 0.

dbisqlc -c "uid=UID;pwd=PWD;eng=DEV;links=tcpip(host=XXXX;port=XXX)" -q   Query.sql  OutputDumpFile   
RC=`echo $?`
if [ $RC != 0 ]
then
    echo "ERROR: Error in DB Query Execution"
fi

Please help how to capture the SQL Error in UNIX for Sybase IQ


Solution

  • According to this documentation, dbisql is recommended over dbisqlc:

    It is recommended that you use the Interactive SQL utility (accessed by using the dbisql command or by choosing Start » Programs » SQL Anywhere 11 » Interactive SQL) where possible because the dbisqlc utility does not support all the features that Interactive SQL does

    It goes on to say:

    Only the dbisql utility has the ability to provide exit codes from a SQL script.

    So based on that, it seems to me that dbisqlc does not convey information via exit codes.