The ITER function
The iteration function, ITER, merges a single value with a partial result and returns a partial result. The ITER function does the main job of processing the information from each row that your query selects. For example, for the AVG aggregate, the ITER function adds the current value to the current sum and increments the row count by one.
The ITER function is required for all user-defined aggregates. If no INIT function is defined for a user-defined aggregate, the ITER function must explicitly handle nulls.
The ITER function obtains the state of the aggregate computation from its state argument.
SPL routines handle null arguments by default. In C and Java™ functions, you must explicitly handle null values in the ITER function and register the function with the HANDLESNULLS modifier.
In C, the ITER function should not maintain additional states in its FPARAM structure because the FPARAM structure is not shared among support functions. However, you can use the FPARAM structure to cache information that does not affect the aggregate result.