SQL>
SQL> create or replace function getArea (i_rad NUMBER)
2 return NUMBER
3 is
4 begin
5 return 3.14 * (i_rad**2);
6 end;
7 /
Function created.
SQL>
SQL> create or replace function f_getDiff(i_rad1 NUMBER,i_rad2 NUMBER)
2 return NUMBER is
3 v_area1 NUMBER;
4 v_area2 NUMBER;
5 v_out NUMBER;
6 begin
7 v_area1 := getArea (i_rad1);
8 v_area2 := getArea (i_rad2);
9 v_out :=v_area1-v_area2;
10 return v_out;
11 end;
12 /
Function created.
SQL>
SQL> declare
2 v_pi NUMBER:=3.14;
3
4
5 begin
6 DBMS_OUTPUT.put_line('Diff between 3 and 4: '||f_getDiff(4,3));
7 DBMS_OUTPUT.put_line('Diff between 4 and 5: '||f_getDiff(5,4));
8 DBMS_OUTPUT.put_line('Diff between 5 and 6: '||f_getDiff(6,5));
9 end;
10 /
Diff between 3 and 4: 21.98
Diff between 4 and 5: 28.26
Diff between 5 and 6: 34.54
PL/SQL procedure successfully completed.
SQL>