Create your own no_data_found EXCEPTION : Your Exception « PL SQL Programming « Oracle PL/SQL Tutorial






SQL>
SQL>
SQL> DECLARE
  2     d VARCHAR2(1);
  3
  4     no_data_found EXCEPTION;
  5
  6  BEGIN
  7
  8     SELECT 'dummy' INTO d FROM dual WHERE 1=2;
  9
 10     IF d IS NULL
 11
 12     THEN
 13
 14        RAISE no_data_found;
 15
 16     END IF;
 17
 18  EXCEPTION
 19
 20     WHEN no_data_found
 21
 22     THEN
 23
 24        DBMS_OUTPUT.PUT_LINE ('Trapped the error!?');
 25  END;
 26  /
DECLARE
*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at line 8


SQL>








24.18.Your Exception
24.18.1.Create your own no_data_found EXCEPTION
24.18.2.An example showing handling of pre-defined exceptions
24.18.3.Catch 'cannot get lock exception'
24.18.4.Handling user-defined exceptions with a WHEN clause
24.18.5.An example of using PRAGMA EXCEPTION_INIT
24.18.6.Assign custom exception a number