Previous Topic: ExpressionsNext Topic: Character-oriented Functions


Introduction to Functions

Functions may appear in the column list of Select SQL statements or in any SQL statement clause where expressions are allowed such as the WHERE clause. Generally, the operands of a character string function can be literal character strings, host variables, or column names. Hexadecimal columns and literals are treated as character strings. When a function expression is used as a SELECT value in the column list, the resulting output variable stem name is function name_n or function name_colname depending upon the particular function and arguments used. The SQL INTO host variable list clause can be used to assign definite names to function result values. Compatible functions may also be nested. Any function value output variables will use the outermost function as the function name portion of the stem variable name.

Operands of functions should be of the data type expected by the function. If an SQL NULL column or value is used as an operand, the resulting value is always NULL. Except for the row COUNT function, aggregate functions such as AVG skip column values that are NULL. The function result is NULL when all the column values are NULL.