Re: How to exit dbaccess if sqlerror ..!
Posted in 1999
Shivaa
You can do this quite simply with a stored procedure with an error handling
block built in, like so:
CREATE PROCEDURE myproc()
DEFINE esql, eisam SMALLINT;
BEGIN
ON EXCEPTION SET esql, eisam
RAISE EXCEPTION esql, eisam;
END EXCEPTION
-- Put all your SQL statements here.
SELECT COUNT(*) FROM ...;
SELECT COUNT(*) FROM ....
END
END PROCEDURE;
To run this you will need to EXECUTE PROCEDURE myproc(); in dbaccess. If
any exception is found in the SELECTs, it will go to the exception handling
block and exit the SP.
HTH
Sujit
shivaa@my-dejanews.com on 02/17/99 08:16:52 AM
Please respond to shivaa@my-dejanews.com
To: informix-list@iiug.org
cc: (bcc: Sujit Pal)
Subject: How to exit dbaccess if sqlerror ..!
I am running multiple/sequential sql statements contained in a sql file
using
'dbaccess' under unix/informix environment .. If one of the sql statements
fail I would like to exit out, without processing any of the subsequent sql
statements .. If I had to do something similar in ORACLE environment with
'sqlplus', I would do something like the following ..
sqlplus user/passwd@somewhere <<!
whenever sqlerror exit sql.sqlcode;
select count(*) from xxx;
select count(*) from yyy;!
If in the above code the first select count(*) fails then sqlplus exits out
without processing the second select statement .. I like to do a similar
thing
in Informix preferably with dbaccess .. Any suggestions .. !
I know that I can wrap each of the sql with a shell and check for error and
exit out if needed .. But that is not an option for me since I am creating
temporary tables that will be lost when I close the dbaccess session and
open
another .. ! I do not want to use any procedural language like 4GL or esqlc
either .. I would like to accomplish this with dbaccess or a similar tool
..
Any input will be greatly appreciated ..
-Thanks
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own