DB2 Version 10.1 for Linux, UNIX, and Windows

Function references (PL/SQL)

Scalar PL/SQL functions can be referenced wherever an expression is supported. Pipelined PL/SQL functions can be referenced in the FROM clause of SELECT statements.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-function-name--+---------------------------+----------------><
                  |    .-,---------------.    |   
                  |    V                 |    |   
                  '-(----parameter-value-+--)-'   

Description

function-name
Specifies an identifier for the function.
parameter-value
Specifies a value for a parameter.

Examples

The following example shows how a function named SIMPLE_FUNCTION, defined in the PL/SQL sample schema, can be called from a PL/SQL anonymous block:
BEGIN
  DBMS_OUTPUT.PUT_LINE(simple_function);
END;
The following example shows how a scalar function and a pipelined function can be used within an SQL statement:
SELECT
   emp.empno, emp.ename, emp.sal, emp.comm,
   emp_comp(sal, comm)+bon.bonus "YEARLY COMPENSATION"
FROM emp, TABLE(bonuses()) as bon(category, bonus)
WHERE bon.category = emp.category