Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / PL SQL Programming
 

Because OTHERS handles all exceptions, you must list it after any specific exceptions in your EXCEPTION block

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>