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.
|