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 exception
9 WHEN ZERO_DIVIDE THEN
10 dbms_output.put_line('Divide by zero in the F_GET_SPEED');
11 return null;
12 end;
13 /
Function created.
SQL>
SQL> declare
2 v_speed NUMBER;
3 begin
4 v_speed:=f_get_speed(10,0);
5 end;
6 /
Divide by zero in the F_GET_SPEED
PL/SQL procedure successfully completed.
SQL>