Using a user-defined function

The invoker of a user-defined function need to perform a sequence of tasks to use the user-defined function.

About this task

  1. Begin general-use programming interface information.The invoker codes an application program, named SALARY_ADJ. The application program contains a static SQL statement that invokes the user-defined function SALARY_CHANGE. SALARY_CHANGE gives an employee a 10% raise if the employee is not a manager. The static SQL statement follows:
    EXEC SQL SELECT  FIRSTNME,
                     LASTNAME
                     SALARY_CHANGE( :hvEMPNO, 10.0 )
               INTO :hvFIRSTNME,
                    :hvLASTNAME,
                    :hvSALARY
               FROM  EMP
              WHERE  EMPNO = :hvEMPNO;                                  
  2. The invoker then precompiles, compiles, link-edits, and binds the invoking application's DBRM into the invoking package. An invoking package or invoking plan is the package or plan that contains the SQL that invokes the user-defined function. After performing these steps, the invoker is the owner of the invoking plan or package.
    Restriction: The invoker must hold the SELECT privilege on the table EMP and the EXECUTE privilege on the function SALARY_CHANGE.
    End general-use programming interface information.