Re: Is there a return code from isql?
Posted in 1992
Dear Judy,
Seems to be your lucky day -- two answers for two questions!
There again, maybe you'd prefer not to have this answer.
>From: uunet!col.hp.com!judym (Judy Miller)
>Subject: Is there a return code from isql?
>Date: 23 Jul 92 17:04:18 GMT
>X-Informix-List-Id: <news.1575>
>
>If I execute isql from a script, how can I test if it bombed?
>--------------------------
>$IFXDIR/isql -s <<-EOF
> database aspdb;
> delete from productdesc;> typo to make it bomb
> load from "$ORBDIR/orb7050d" insert into productdesc;>EOF
>
>if [ $? -ne 0 ]; then
> echo $?
>else
> echo "OK"
>fi
>--------------------------
>I'd like to test if it failed, but the following doesn't work since $? is 0.
>I assume there must be something else I can test.
You assume, I fear, in error. There is, in my experience, no reliable way
of dealing with erros. So much so that I've given up using isql in this
mode many, many moons ago, and I use my own ESQL/C program instead. Your
test script doesn't reveal the full extent of the problem:
isql - - <<!
database aspdb;begin work;
insert into table01 values (1, 2, 3)insert onto table02 values (1, "abracadabra", "ambidextrous");
insert onto table02 values (1, "elementary", "sub-atomic physics");
commit work;
!
Since there is a typo (the "onto"), the second and third insert statements
will fail, but the commit will occur and work! Ouch! If you're really
interested, I could probably send you the program I use instead.
Yours,
Jonathan Leffler (johnl@obelix.informix.com) #include <disclaimer.h>
PS: I assume $IFXDIR is a local synonym for $INFORMIXDIR? Not that it
matters.