RE: Catch Informix error message in a shell file
Posted in 2000
Nicer in this case just to test for the procedure's existence first:
IsThere=`dbaccess DB_NAME <<! | grep 'x'
output to pipe 'cat' without headings
select 'x' from sysprocedures
where procname = "YOURPROCEDURE"
!
`
if [ "$IsThere" ]
then
dbaccess DB_NAME <<!
drop procedure YOURPROCEDURE;!
fi
# now create the procedure . . .
> -----Original Message-----
> From: mars1972@my-deja.com [SMTP:mars1972@my-deja.com]
> Sent: Wednesday, February 02, 2000 10:41 AM
> To: informix-list@iiug.org
> Subject: Re: Catch Informix error message in a shell file
>
> 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.
>
> Not a very clean way, I'm afraid. You can redirect the output and error
> to a file, then read the file and check for the string you want to
> ignore. If it's anything else, write it for the user. If it is the
> error you expect, you can write the standard SNAFU message to them.
>
> (cat create_sp.dat) | dbaccess DB_NAME >outfile 2>errfile;
> while read $errline
> do
> ...
> done <errfile
>
>
> --
> # unrm /
> ksh: unrm: not found
> # man cpio
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.