Because OTHERS handles all exceptions, you must list it after any specific exceptions in your EXCEPTION block. : Exception « PL SQL Programming « Oracle PL/SQL Tutorial






SQL>
SQL> BEGIN
  2     DBMS_OUTPUT.PUT_LINE(1 / 0);
  3  EXCEPTION
  4     WHEN OTHERS THEN
  5        DBMS_OUTPUT.PUT_LINE('An exception occurred');
  6     WHEN ZERO_DIVIDE THEN
  7        DBMS_OUTPUT.PUT_LINE('Division by zero');
  8  END;
  9  /
   WHEN OTHERS THEN
   *
ERROR at line 4:
ORA-06550: line 4, column 4:
PLS-00370: OTHERS handler must be last among the exception handlers of a block
ORA-06550: line 0, column 0:
PL/SQL: Compilation unit analysis terminated


SQL>








24.14.Exception
24.14.1.Exceptions
24.14.2.Types of more commonly used Exceptions
24.14.3.Exception Handling
24.14.4.The NULL Statement
24.14.5.ZERO_DIVIDE Exception
24.14.6.When the exception occurs, program control passes to the EXCEPTION block where the WHEN clause is examined for a matching exception.
24.14.7.Understanding Different Exception Types
24.14.8.DUP_VAL_ON_INDEX Exception
24.14.9.INVALID_NUMBER Exception
24.14.10.Catch 'divide by zero' exception
24.14.11.OTHERS Exception
24.14.12.Because OTHERS handles all exceptions, you must list it after any specific exceptions in your EXCEPTION block.
24.14.13.Declare variables in exception handler
24.14.14.Data not found exception
24.14.15.Too many rows exception