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






Datatype families are groups of similar datatypes.

For example, CHAR and VARCHAR2 are used to describe exactly the same kind of textual data, so they belong to the same family.

You can overload only between different families.

The following code is an example of declaring a different datatype family:

SQL> declare
  2    function getArea(i_rad NUMBER, i_prec NUMBER) return NUMBER is
  3        v_pi NUMBER:=3.14;
  4    begin
  5       return trunc(v_pi * (i_rad ** 2),i_prec);
  6    end;
  7    function getArea(i_rad NUMBER, i_ignore_yn VARCHAR2) return NUMBER is
  8        v_pi NUMBER:=3.14;
  9    begin
 10       if i_ignore_yn='Y' and i_rad < 5 then
 11         return 0;
 12       else
 13         return v_pi * (i_rad ** 2);
 14       end if;
 15    end;
 16  begin
 17    DBMS_OUTPUT.put_line('Area (R=3):'||getArea(3,1));
 18    DBMS_OUTPUT.put_line('Area (R=3):'||getArea(3,'N'));
 19  end;
 20  /
Area (R=3):28.2
Area (R=3):28.26

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.