What is the purpose of RAISE_APPLICATION_ERROR?

I understand that I am RAISE_APPLICATION_ERROR

linking a message error that only makes sense to the user. But can't the user just write a similar exception like this?

DECLARE
e_negative EXCEPTION;


BEGIN
IF v_sid < 0 THEN
RAISE e_negative;
...

EXCEPTION
WHEN e_negative THEN
DBMS_OUTPUT.PUT_LINE ('An id cannot be negative');

      

+3


source to share


1 answer


raise_application_error

does more than print an error message to the console (for example dbms_output.put_line

).

First, it is an actual error - it does not execute the statement, ends the execution of the current block, and propagates to outer blocks (similar to throw

Java or raise

Python).



Second, it actually returns this error regardless of the console. dbms_output

messages can be disabled or ignored depending on the client. Engaging an application error allows you to return error details regardless of the client.

+9


source







All Articles