Mapping a user-defined error code to an EXCEPTION variable
SQL>
SQL> DECLARE
2 e EXCEPTION;
3 PRAGMA EXCEPTION_INIT(e,-20001);
4 BEGIN
5 RAISE_APPLICATION_ERROR(-20001,'A less than original message.');
6 EXCEPTION
7 WHEN e THEN
8 dbms_output.put_line(SQLERRM);
9 END;
10 /
ORA-20001: A less than original message.