A post in the 'Unix Shell Scripts' forum of this site ...

Thanks Laura


Re: Passing Sql Errors to Unix ksh Script

Originally posted by manialg
Can someone tell me how to pass the db2 sql errors out to
a ksh script? I'm new to db2 and we have several scripts that
run at night - and where the unix script processes ok we are
getting some sql errors that we'd like to trap for -


Here's a quick example of an easy way to do it:


SQLCODE=`db2 -ec +o "update db cfg for $DBNAME using dbheap 11370"`;

if [ $SQLCODE -ne 0 ]
echo " "
echo "Error: Failed to Update Db Cfg for $DBNAME"
echo "Error: SQLCODE = $SQLCODE"
exit 1