Re: Catch Informix error message in a shell file
Posted in 2000
"Demus, Alan" wrote:
>
> 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 . . .
Even nicer:
IsThere=`dbaccess DB_NAME <<! 2>/dev/null
OUTPUT TO PIPE 'cat' WITHOUT HEADINGS
SELECT 1
FROM sysprocedures
WHERE procname = "YOURPROCEDURE"!
`
if [ $IsThere ]
then
dbaccess DB_NAME <<-!
DROP PROCEDURE YOURPROCEDURE; !
fi
Or combining the two into a single database connection:
WasThere=`dbaccess DB_NAME <<! 2>/dev/null
DROP PROCEDURE YOURPROCEDURE!
`
if [ "X$WasThere" = "X" ]
then
echo "Procedure dropped"
fi
Of course you might want to check why it didn't drop and make sure it
was because it didn't exist and not that you didn't have permission or
something worse. ;-)
Cheers,
--
Mark.
+----------------------------------------------------------+-----------+
| Mark D. Stock mailto:mdstock@mydas.freeserve.co.uk |//////// /|
| http://www.informix.com http://www.informixhandbook.com |///// / //|
| http://www.iiug.org +-----------------------------------+//// / ///|
| |What year 2000 bug? year 2000 bug? |/// / ////|
| |year 2000 bug? year 2000 bug? year |// / /////|
| |2000 bug? year 2000 bug? year 1900 |/ ////////|
+----------------------+-----------------------------------+-----------+