Posted By

geekzspot on 02/01/13


Tagged


Versions (?)

Oracle User-Defined Exception


 / Published in: PL/SQL
 

You can create your own Exceptions in PL/SQL

  1. -- User-defined Exception.
  2. user_defined_exception EXCEPTION;
  3. RAISE user_defined_exception;
  4. WHEN user_defined_exception THEN
  5. DBMS_OUTPUT.PUT_LINE(SQLERRM); -- Gives "User-Defined Exception".
  6. /
  7.  
  8.  
  9.  
  10.  
  11. -- User-defined Exception with a user-defined error message.
  12.  
  13. user_defined_exception EXCEPTION;
  14. PRAGMA EXCEPTION_INIT( user_defined_exception, -20001 );
  15. raise_application_error( -20001, 'This is a user defined error' );
  16. WHEN user_defined_exception THEN
  17. DBMS_OUTPUT.PUT_LINE( SQLERRM );
  18. /

Report this snippet  

You need to login to post a comment.