27. 19. 5. There are some restrictions on overloading: |
|
You can't overload standalone procedures or functions. |
The second definition simply overwrites the first one. |
You can't overload functions that differ only by the datatype of the return value. |
If you need to implement this requirement, use overloaded procedures with OUT parameters. |
SQL> declare
2 function getArea(i_rad NUMBER) return NUMBER
3 is
4 v_pi NUMBER:=3.14;
5 begin
6 return v_pi * (i_rad ** 2);
7 end;
8 function getArea (i_length NUMBER, i_width NUMBER) return NUMBER
9 is
10 begin
11 return i_length * i_width;
12 end;
13 begin
14 DBMS_OUTPUT.put_line('Area (R=3): ' ||getArea(3));
15 DBMS_OUTPUT.put_line('Area (R=3): ' ||getArea('3'));
16 end;
17 /
Area (R=3): 28.26
Area (R=3): 28.26
PL/SQL procedure successfully completed.
|
|