If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
DB2 v8.2 ESE on AIX v5.3 / DB2 v9.5.1 ESE on AIX v6.1
anyone please - how can we get full sql code in the script? Like in example below we are using this logic to process sql errors:
--------------------------------------------------------------
function check_SQL
{
mSQLCode=$?
if [ $mSQLCode -ne 0 ]; then
echo "\nSCRIPT FAILED!!! SQL error: $1\n " | tee -a $mLogFile
exit 1
fi
}
db2 -v connect to $mdbName >> $mLogFile
check_SQL "Connect to database failed!"
-------------------------------------------------------------
output (in file):
connect to
SQL0104N An unexpected token "END-OF-STATEMENT" was found following "TO".
Expected tokens may include: "<identifier>". SQLSTATE=42601
-------------------------------------------------------------
So in function we get and process only sqlcode 0 or 'not 0'. In this case above mSQLCode=4 but we would like to have 'SQL0104N'.
Thanks in advance
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
You can use option '-a' for the DB2 CLP and parse the SQLCODE from the dumped SQLCA.
the problem is that results and sql erros go to the same output. does this way separate them? would you happen to have an example, Knut?
thanks in advance
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
You are right on that the SQLCA is written to standard output - like the results. So you would have to parse the output. But that is really simple and straight-forward with a regexp (Perl style) like:
You are right on that the SQLCA is written to standard output - like the results. So you would have to parse the output. But that is really simple and straight-forward with a regexp (Perl style) like: