Re: Catch Informix error message in a shell file
Posted in 2000
>
> In article <38984099.60712806@news.ca.geac.com>,
> i.sokolsky@geac.com (Igor) wrote:
> > Hi All
> >
> > I use following unix shell file to DROP and than to create Stored
> > Procedure : ( cat create_sp.dat ) | dbaccess DB_NAME;
> > But I getting a informix error message when Stored Procedure is not in
> > db.It try to drop it, but if I run this script for first time it is
> > not there yet. Is that possible to catch this error somehow and to
> > give user some normal message.
>
Take the drop out of the create file and check to see if the SPL is
there,
if it is then drop it, something like the following should be you
started
#! /bin/ksh
SPLNAME=`egrep "^CREATE PROCEDURE" <SPLFILE> | awk '{print $3}'`
NUMFND=`dbaccess <DBNAME> - <<-EOF 2>/dev/null | awk '/ [0-9]/'{print
$1}'
select count(*)
from sysprocedure
where procname = "${SPLNAME}";EOF
'
if [ ${NUMFND} != 0 ]
then
dbaccess <DBNAME> - <-EOF >/dev/null 2>&1
drop procedure ${SPLNAME};
EOF
if [ $? != 0 ]
then
echo "Failed to drop "${SPLNAME}
exit 1
fi
fi
dbaccess <DBNAME> <SPLFILE> >/dev/null 2>&1
if [ $? != 0 ]
then
echo "Failed to build SPL "${SPLNAME}
exit 2
fi
fi
--
Paul Watson #
WF Software # You are only young once
Tel ++44 1436 674729 # But you can be immature for ever
Fax ++44 1436 678693 #
www.wfsoftware.com/informix #