Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: user defined exception.
This is remarkably easy:
CREATE OR REPLACE PROCEDURE xyz IS
x PLS_INTEGER;
rtfm EXCEPTION;
BEGIN
SELECT COUNT(1)
INTO x
FROM dual;
IF x > 1 THEN
RAISE rtfm;
END IF;
EXCEPTION
WHEN rtfm THEN
DBMS_OUPUT.PUT_LINE('Another User Did Not RTFM');
WHEN OTHER THEN
DBMS_OUPUT.PUT_LINE('Something Else Happened');
END;
/
Daniel Morgan
Hugues Landry wrote:
> Hi Everyone,
> Does anyone know how i can register an exception into the system so
> that when it throws it display a message specified by me !!
>
> Here's some code
>
> CREATE OR REPLACE PROCEDURE throwMyException
> IS
> myException EXCEPTION;
> BEGIN
> RAISE myException;
> END;
>
> When called this method produce this output :
>
> ORA-06510: PL/SQL: unhandled user-defined exception
> ORA-06512: at "TESTDB.THROWMYEXECPTION", line 5
>
> I know i can use the pragma exception_init to associate my exception
> to an already existing one, but is there a way to define this myself
> ??
>
> Hugues Landry
Received on Tue Jan 22 2002 - 06:44:12 CST