Re: ESQL/C calling SPs - seg fault with RETURN from EXCEPTION block
Posted in 1999
Hello All
Please ignore this mail. I solved my problem. Turns out I was not doing things
exactly as I said I was. Specifically I was not sizing my sqlda structure
properly. I guess I should have looked harder before posting.
If you have spent time puzzling over this, thanks for the effort and sorry for
consuming your bandwidth.
Thanks
Sujit
From: Sujit Pal on 12/16/99 03:18 PM
To: informix-list@iiug.org
cc:
Subject: ESQL/C calling SPs - seg fault with RETURN from EXCEPTION block
Hello All
I am using an ESQL/C program to execute a set of Stored Procedures. Because the
Stored Procedures that will execute will not be known in advance, I am using the
sqlda structure to fetch into, and basically treating the SP like a SELECT call
(based heavily on the code example in demo/esqlc/unload.ec).
My problem comes in when I use the exception block to return an error status.
For example, if I do:
CREATE PROCEDURE myproc (myinarg1, myinarg2)
RETURNING status INTEGER, myout CHAR(20);
BEGIN
ON EXCEPTION SET esql, eisam, emesg
IF (esql = -746) THEN
RETURN 1001, NULL WITH RESUME;
END IF;
END EXCEPTION WITH RESUME;
FOREACH myselect
-- do something
IF (someproblem) THEN
-- RETURN 1001, NULL WITH RESUME;
RAISE EXCEPTION -746, 0, NULL;
ELSE
RETURN 0, myout WITH RESUME;
END IF;
END FOREACH;
END
END EXCEPTION;
If I force the SP to raise exception, then it seg faults on the fetch after the
exception is raised (returns 1001 in status). However, if I return the status
instead of raising exception, then it goes through fine.
I would really like to have a generic error handling technique in my SPs. Is
there a way. I am not posting the ESQL/C program here because its really large
and its really very similar to the unload.ec demo program, except I am doing an
EXECUTE PROCEDURE instead of a SELECT.
My ESQL/C version = 9.15
My Informix Engine = 7.30.UC8
My Operating system = Sun OS 5.5.1
TIA
Sujit