Subject Using the text of an exception
Author Roger Vellacott
We have a lot of complex PSQL, which constructs informative exceptions on the fly.

We have a general-purpose exception defined as
CREATE EXCEPTION FLEX_EXCEPTION 'An error has occurred';

And it is used like this
EXCEPTION FLEX_EXCEPTION ('The peg '||:PEG_CODE||' doesn`t fit in the hole '||:HOLE_CODE);

Is there any way I can handle the exception, and use the text of the exception for an error log? I would like to be able to do something like the following

CREATE PROCEDURE MY_PROC AS
BEGIN
<do something complicated, which updates tables which call triggers, which
call procedures, which somewhere or other causes an error like the one above>
WHEN ANY DO
INSERT INTO PROBLEM_LOG(REFS...,EXCEPTION_TEXT) VALUES(:REFS..., :LAST_EXCEPTION_TEXT);

END



Roger Vellacott
Passfield Data Systems