Code with No Exception Handler : Handle Exception « PL SQL Programming « Oracle PL/SQL Tutorial






SQL>
SQL> create or replace function f_get_speed(i_distance NUMBER, i_timeSec NUMBER)
  2  return NUMBER
  3  is
  4     v_out NUMBER;
  5  begin
  6     v_out:= i_distance/i_timeSec;
  7     return v_out;
  8  end;
  9  /

Function created.

SQL>
SQL> declare
  2      v_speed NUMBER;
  3  begin
  4      v_speed:=f_get_speed(10,0);
  5  end;
  6  /
declare
*
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at "JAVA2S.F_GET_SPEED", line 6
ORA-06512: at line 4


SQL>








24.15.Handle Exception
24.15.1.Code with No Exception Handler
24.15.2.Code with Conditional Control to Avoid an Exception
24.15.3.Code with Explicit Handler for Predefined Exception
24.15.4.Handling an Unnamed Exception
24.15.5.Handling a custom exception
24.15.6.An example showing continuing program execution after handling exception
24.15.7.The OTHERS Exception Handler
24.15.8.Assigning a Name to Predefined Exception Code
24.15.9.Using SQLCODE for error code and SQLERRM for error message
24.15.10.Catch custom exception
24.15.11.Handling exceptions without halting the program
24.15.12.Select into statement with exception catch statement
24.15.13.Check OTHERS exception
24.15.14.Error message code and text
24.15.15.Using PRAGMA EXCEPTION_INIT
24.15.16.NO data found
24.15.17.TOO_MANY_ROWS Exception
24.15.18.Use a nested block to catch exceptions from singleton SELECT.