Oracle PL/SQL - Overloading function: Names of parameters

Introduction

You can overload program units by using different names of parameters as long as you use named notation when you call the program units:

Demo

SQL>
SQL> declare-- from www . ja  va2s. c om
  2        function f_getArea_Nr(i_rad_nr NUMBER, i_prec_nr NUMBER)
  3           return NUMBER
  4        is
  5            v_pi_nr NUMBER:=3.14;
  6       begin
  7           return trunc(v_pi_nr * (i_rad_nr ** 2),i_prec_nr);
  8        end;
  9        function f_getArea_Nr(i_length_nr NUMBER, i_width_nr NUMBER)
 10           return NUMBER
 11        is
 12       begin
 13           return i_length_nr * i_width_nr;
 14        end;
 15  begin
 16      DBMS_OUTPUT.put_line('Area (R=3): '||f_getArea_Nr(i_rad_nr=>3,i_prec_nr=>1));
 17      DBMS_OUTPUT.put_line('Area (2x3): '||f_getArea_Nr(i_length_nr=>2,i_width_nr=>3));
 18  end;
 19  /
Area (R=3): 28.2
Area (2x3): 6

PL/SQL procedure successfully completed.
SQL>

Related Topic