Re: Question regarding Stored Procedures.....
Posted in 1999
Jack
Yes, you can make SPL report on the error. Just use a ON EXCEPTION block
to set the sqlca.sqlcode and the isam error and make it RAISE EXCEPTION
error. You can then either raise system exceptions automatically and your
own exceptions by putting a RAISE EXCEPTION in the program block. Here is a
short example:
CREATE PROCEDURE myproc (arg1 LIKE tab1.col1, arg2 LIKE tab2.col2)
RETURNING INTEGER, CHAR(30);-- Define all args here
ON EXCEPTION SET esql, eisam, emesg
RAISE EXCEPTION esql, eisam, emesg;
END EXCEPTION
LET myval = null;
SELECT tab1.col1 INTO myval
FROM tab1
WHERE tab1.col1 = arg1;
IF (myval IS NULL) THEN
RAISE EXCEPTION -901, 0, "Invalid Argument";
ELSE
-- do something else
END IF;
END PROCEDURE;
You can trap the sqlca.sqlcode in your ESQL/C program, its the same as the
value of esql.
HTH
Sujit
Jack Murphy <jmurphy@fore.com> on 07/29/99 12:28:51 AM
Please respond to Jack Murphy <jmurphy@fore.com>
To: informix-list@iiug.org
cc: (bcc: Sujit Pal)
Subject: Question regarding Stored Procedures.....
Hi All,
I am calling some Informix SPL from within a C+ program..is there a way
that
I can get a return code from the SPL to tell me if it was successful or
not?
The SPL routines do some deletions and insertions..nothing too radical.
I am seeing problems where rows are locked in a table and the Stored
Procedure cant access the data, this causes it to fail but we need a way to
trap that failure.
Thanks for your help,
Jack