Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / Function Procedure Packages
 

Names of parameters

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.