The INIT function

The INIT function initializes the data structures required by the rest of the computation of the aggregate. For example, if you write a C function, the INIT function can set up large objects or temporary files for storing intermediate results. The INIT function returns the initial result of the aggregate, which is of the state type.

The INIT function can take one or two arguments. The first argument must be the same type as the column that is aggregated. The database server uses the type of the first argument to resolve overloaded INIT functions.

For C and Java™, the first argument of the INIT function is a placeholder argument and always has a null value. Therefore, all functions that serve as INIT functions must be defined with the HANDLESNULLS modifier.


Copyright© 2020 HCL Technologies Limited