Catch Informix error message in a shell file
Posted in 2000
Topics: Stored Procedures & SPL, Server Administration
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.
Thanks
Regards
Igor
Igor wrote:
> 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.
If you get SQLCMD from the IIUG software archives, you can
control the whole shebang as you want:
sqlcmd -d DB_NAME <<!
continue on;
error /dev/null;
drop procedure procname;error /dev/stderr;
continue off;
input create_sp.dat;
!
Even if your o/s does not have an actual /dev/stderr file, SQLCMD
supports the concept. If you don't mind having the error reported,
you don't have to fiddle with the error directives. You could also
specify -c on the command line to have SQLCMD continue after errors,
reducing the whole script to:
sqlcmd -d DB_NAME -c -e 'drop procedure procname' -f create_sp.dat
Yes, I wrote it, so it is not an unbiassed opinion.
On the other hand, I wanted to be able to deal with situations
such as this, so I wrote a tool that could do it.
--
Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net)
Guardian of DBD::Informix v0.95 -- see http://www.perl.com/CPAN
#include <disclaimer.h>