Nested function in anonymous block : Nested Functions « Function Procedure Packages « Oracle PL/SQL Tutorial






SQL> set echo on
SQL> set serveroutput on
SQL>
SQL> declare
  2
  3     function myFunction (myValue in number,myFactor in number) return number is
  4
  5         myFactor_to_use  number;
  6         minimum_wage  number := 5;
  7     begin
  8         if (myFactor is null) or (myFactor < minimum_wage) then
  9             myFactor_to_use := minimum_wage;
 10         else
 11             myFactor_to_use := myFactor;
 12         end if;
 13
 14         return myValue * myFactor_to_use;
 15      end;
 16  begin
 17    dbms_output.put_line(myFunction(40,10));
 18    dbms_output.put_line(myFunction(40,2));
 19    dbms_output.put_line(myFunction(40,null));
 20  end;
 21  /
400
200
200

PL/SQL procedure successfully completed.

SQL>
SQL>








27.2.Nested Functions
27.2.1.Nested function in anonymous block
27.2.2.Define inner function to calculate age