Implementing a user-defined aggregate function with C user-defined functions
To implement a user-defined aggregate function with C user-defined functions:
- Determine the content and data type of the aggregate state.
- Write the C UDRs that implement the required aggregate support functions for the data type on which you want to implement the user-defined aggregate.
- Define the user-defined aggregate in the database with the CREATE AGGREGATE and CREATE FUNCTION statements.
After you complete these steps, you can use the aggregate in an SQL statement.
The following sections describe each of
these development steps in more detail and use the SQSUM1 user-defined
aggregate (which Table 1 describes)
as an example.
User-Defined Aggregate | Description | Definition |
---|---|---|
SQSUM1 | Sums all values and calculates the square of this sum | (x1 + x2 + x3 + ... )2 |