Names of parameters : Overloading « Function Procedure Packages « Oracle PL/SQL Tutorial






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

SQL>
SQL> declare
  2      function getArea(i_rad NUMBER, i_prec NUMBER)
  3         return NUMBER
  4      is
  5          v_pi NUMBER:=3.14;
  6      begin
  7         return trunc(v_pi * (i_rad ** 2),i_prec);
  8      end;
  9      function getArea(i_length NUMBER, i_width NUMBER)
 10         return NUMBER
 11      is
 12      begin
 13         return i_length * i_width;
 14      end;
 15  begin
 16     DBMS_OUTPUT.put_line('Area (R=3): '||getArea(i_rad=>3,i_prec=>1));
 17     DBMS_OUTPUT.put_line('Area (2x3): '||getArea(i_length=>2,i_width=>3));
 18  end;
 19  /
Area (R=3): 28.2
Area (2x3): 6

PL/SQL procedure successfully completed.








27.19.Overloading
27.19.1.Overloading calls
27.19.2.Number of parameters
27.19.3.Names of parameters
27.19.4.Datatype family of parameters
27.19.5.There are some restrictions on overloading:
27.19.6.More than one match was found so Oracle raised a special error.