Wednesday, February 6, 2013

Oracle PL/SQL - Raise User-Defined Exception With Custom SQLERRM - Stack Overflow


User defined Exception with Naming and assigning the Error Code no.

  1  declare
  2    ex_custom EXCEPTION;
  3    PRAGMA EXCEPTION_INIT( ex_custom, -20001 );
  4  begin
  5    raise_application_error( -20001, 'This is a custom error' );
  6  exception
  7    when ex_custom
  8    then
  9      dbms_output.put_line( sqlerrm );
 10* end;
SQL> /
ORA-20001: This is a custom error

PL/SQL procedure successfully completed.

No comments:

Post a Comment