Was this helpful?
Function Definitions for Aggregates
Functions for user-defined types require the following:
A function definition (using the IIADD_FO_DFN structure) to define the function name
A function instance definition (using the IIADD_FI_DFN structure) to define the functions that will perform the operations
Function definitions for count(), max(), min() and sum() are already included in Ingres, in the same sense that arithmetic and comparison operations are pre-defined for user-defined data types; however, avg() is NOT pre-defined. Users can also code their own aggregate functions with distinct function names. The IIADD_FO_DFN structure instance must define “fod_type” to be II_AGGREGATE in this case.
Like all functions on user-defined data types, aggregate functions must also include definitions of each function instance for the function on a specific user-defined type. These are defined by IIADD_FI_DFN structure instances, and for aggregate functions they must include an “fid_optype” of II_AGGREGATE.
The instances of the function instance structure must be in a particular sorted sequence. Function instances with fid_optype of II_AGGREGATE must be placed between those for II_OPERATOR and II_NORMAL. If the function instance is for one of the standard Ingres aggregates, the “fid_opid” field must be set to the appropriate code (II_COUNT_OP for COUNT, II_MAX_OP for MAX, II_MIN_OP for MIN, II_SUM_OP for SUM). If the function instance is for a user-defined aggregate function, the fid_opid field must contain the value from the “fod_id” field of the corresponding IIADD_FO_DFN structure instance.
Note:  The function instance definitions must not use the II_RES_EXTERN value for the “fid_rltype” field.
Last modified date: 04/03/2024