PDA

View Full Version : Passing Sql Errors to Unix ksh Script


manialg
10-10-02, 13:17
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 -

Thanks

llsmith
12-27-02, 13:08
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 -

Thanks

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


SQLCODE=0

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

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