Functions are a type of FairCom DB SQL expression that return a value based on the argument they are supplied. FairCom DB SQL supports two types of functions:
- Aggregate functions calculate a single value for a collection of rows in a result table (if the function is in a statement with a GROUP BY clause, it returns a value for each group in the result table). Aggregate functions are also called set or statistical functions. Aggregate functions cannot be nested.
- Scalar functions calculate a value based on another single value. Scalar functions are also called value functions. Scalar functions can be nested.
FairCom DB SQL does not provide a mechanism for calling a scalar function directly from a user-defined function. To use scalar functions, it is necessary to call the function from within a FairCom DB SQL statement. FairCom DB SQL defines the special table SYSCALCTABLE which has only one row for use in situations where all the data is in the inputs.