SQL>
SQL> create or replace function f_get_speed(i_distance NUMBER, i_timeSec NUMBER)
2 return NUMBER
3 is
4 v_out number:=0;
5 begin
6 if i_timeSec!=0 then
7 v_out:= i_distance/ i_timeSec;
8 end if;
9 return v_out;
10 end;
11 /
Function created.
SQL>
SQL>
SQL> declare
2 v_speed NUMBER;
3 begin
4 v_speed:=f_get_speed(10,0);
5 end;
6 /
PL/SQL procedure successfully completed.
SQL>
|