SQL Reference

Scalar Functions

A scalar function can be used wherever an expression can be used. However, the restrictions that apply to the use of expressions and column functions also apply when an expression or column function is used within a scalar function. For example, the argument of a scalar function can be a column function only if a column function is allowed in the context in which the scalar function is used.

The restrictions on the use of column functions do not apply to scalar functions because a scalar function is applied to a single value rather than a set of values.

Example: The result of the following SELECT statement has as many rows as there are employees in department D01:

   SELECT EMPNO, LASTNAME, YEAR(CURRENT DATE - BRTHDATE)
     FROM EMPLOYEE
     WHERE WORKDEPT = 'D01'

The scalar functions that follow may be qualified with the schema name (for example, SYSIBM.CHAR(123)).


[ Top of Page | Previous Page | Next Page ]