1)manager exception
1@@@@exception packages
@@@
@@@<1> create a customized exception
@@@
Note:
  I declare the exception on the top of anonymous block. If I have many program want to use
  the same exception, I would repeat declare them.
SYS@ocm> !cat tmp.sql
DECLARE
  exception_sal_too_low CONSTANT NUMBER := -20001;
  sal_too_low EXCEPTION;
  PRAGMA EXCEPTION_INIT(sal_too_low, -20001);
BEGIN
  RAISE_APPLICATION_ERROR(exception_sal_too_low, 'Salary is too low!!!');
END;
/

SYS@ocm> /
DECLARE
*
ERROR at line 1:
ORA-20001: Salary is too low!!!
ORA-06512: at line 6


@@@
@@@<2> create a package to manager the repeated exceptions
@@@
Note:
  All the program could use the exceptions without declare it.
SYS@ocm> !cat tmp02.sql
CREATE OR REPLACE PACKAGE exception_names
IS
  exception_sal_too_low CONSTANT NUMBER := -20001;
  sal_too_low EXCEPTION;
  PRAGMA EXCEPTION_INIT(sal_too_low, -20001);
END;
/
SYS@ocm> /
Package created.


SYS@ocm> !cat tmp.sql
BEGIN
  RAISE_APPLICATION_ERROR(exception_names.exception_sal_too_low, 'Salary is too low!!!');
END;
/
SYS@ocm> @tmp.sql
BEGIN
*
ERROR at line 1:
ORA-20001: Salary is too low!!!
ORA-06512: at line 2