PL/SQL RAISE_APPLICATION_ERROR
PL/SQL RAISE_APPLICATION_ERROR
In PL/SQL RAISE_APPLICATION_ERROR function use to assign exception name and exception error code.
Syntax
raise_application_error(error_number, error_message);
Example
raise_app_error.sql
SQL>edit user-named_exp
DECLARE
myex EXCEPTION;
n NUMBER := &n;
BEGIN
FOR i IN 1..n LOOP
dbms_output.put.line(i);
IF i=n THEN
RAISE myex;
END IF;
END LOOP;
EXCEPTION
WHEN myex THEN
RAISE_APPLICATION_ERROR(-20015, 'loop finish');
END;
/
Result
SQL>@raise_app_error
n number &n= 5
1
2
3
4
5
ORA-20015: loop finish
PL/SQL procedure successfully operation.
n number &n= 5
1
2
3
4
5
ORA-20015: loop finish
PL/SQL procedure successfully operation.
When RAISE_APPLICATION_ERROR execute it's return error message and error code looking same as oracle built-in error.