Function invocation

Each reference to a scalar or aggregate function (either built-in or user-defined) conforms to the following syntax: 34

Click to skip syntax diagram
Read syntax diagramSkip visual syntax diagramfunction-invocation:
 
                                  (1)
|--function-name--(--+----------+-------+----------------+--)---|
                     +-ALL------+       | .-,----------. |
                     '-DISTINCT-'       | V            | |
                                        '---expression-+-'
 
Notes:
  1. The ALL or DISTINCT keyword can be specified only for an aggregate function or a user-defined function that is sourced on an aggregate function.

Each reference to a table function conforms to the following syntax:

Click to skip syntax diagram
Read syntax diagramSkip visual syntax diagram>>-TABLE--(--function-name--(--+----------------+--)--)--correlation-clause-><
                               | .-,----------. |
                               | V            | |
                               '---expression-+-'
 

In the above syntax, expression is the same as it is for a scalar or aggregate function. See Expressions for other rules for expression.

When the function is invoked, the value of each of its parameters is assigned, using storage assignment, to the corresponding parameter of the function. Control is passed to external functions according to the calling conventions of the host language. When execution of a user-defined aggregate or scalar function is complete, the result of the function is assigned, using storage assignment, to the result data type. For details on the assignment rules, see Assignments and comparisons.

Table functions can be referenced only in the FROM clause of a subselect. For more details on referencing a table function, see the description of the FROM clause in from-clause.


34.
A few functions allow keywords instead of expressions. For example, the CHAR function allows a list of keywords to indicate the desired date format. A few functions use keywords instead of commas in a comma separated list of expressions. For example, the EXTRACT, TRIM, and POSITION functions use keywords.