Raise User-defined exceptions : Your own Exception « PL SQL « Oracle PL / SQL






Raise User-defined exceptions


SQL>
SQL>
SQL>
SQL> DECLARE
  2    myException EXCEPTION;
  3  BEGIN
  4
  5      RAISE myException;
  6
  7      DBMS_OUTPUT.PUT_LINE('This enrollment has been deleted');
  8  EXCEPTION
  9
 10   WHEN myException THEN
 11    DBMS_OUTPUT.PUT_LINE('This enrollment is already confirmed');
 12    DBMS_OUTPUT.PUT_LINE('It cannot be deleted');
 13  END;
 14
 15  /
This enrollment is already confirmed
It cannot be deleted

PL/SQL procedure successfully completed.

SQL>
           
       








Related examples in the same category

1.Define and use your own exception
2.How to define your own exception
3.used defined exception
4.Using SQLCODE and SQLERRM
5.Handling a user-defined exception
6.Insert Exception message to an audit table