Define local exceptioon variable. : RAISE « PL SQL Statements « Oracle PL/SQL Tutorial






SQL>
SQL> SET SERVEROUTPUT ON SIZE 1000000
SQL>
SQL> -- Build an anonymous block that will trigger an error.
SQL> DECLARE
  2
  3
  4    my_error          EXCEPTION;
  5    PRAGMA EXCEPTION_INIT(my_error,-20001);
  6
  7  BEGIN
  8
  9    -- Raise the exception.
 10    RAISE my_error;
 11
 12  EXCEPTION
 13
 14    WHEN my_error THEN
 15      dbms_output.put_line('RAISE my_error'||CHR(10)
 16                           ||'SQLCODE ['||SQLCODE||']'||CHR(10)
 17                           ||'SQLERRM ['||SQLERRM
 18                           ||'User defined error.]');
 19
 20  END;
 21  /
RAISE my_error
SQLCODE [-20001]
SQLERRM [ORA-20001: User defined error.]

PL/SQL procedure successfully completed.

SQL>








22.24.RAISE
22.24.1.Check condition first, then raise exception
22.24.2.Re-raise the exception to indicate there is a problem
22.24.3.Raise the exception.
22.24.4.Define local exceptioon variable.