Informix Error -9410: User-defined aggregate <aggregate-name> has two arguments but no </aggregate-name> INIT function specified.
Cause and resolution
User-defined aggregate <aggregate-name> has two arguments but no </aggregate-name> INIT function specified.
The user-defined aggregate in your SELECT statement specifies a set-up argument. However, the CREATE AGGREGATE statement that defined this aggregate has not specified an INIT support function. The handling of a set-up argument must occur in an INIT function.
You can either call the user-defined aggregate without a set-up argument or implement a set-up argument for the user-defined aggregate. To implement a set-up argument, take the following actions:
- Write an INIT support function that handles the set-up argument. - Register the INIT function (with CREATE FUNCTION).
- Drop the user-defined aggregate (with DROP AGGREGATE).
- redefine the user-defined aggregate (WITH CREATE AGGREGATE), providing the INIT modifier to specify the new INIT support function.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-9410 fires when an aggregate call includes a set-up (second) argument, but the aggregate's CREATE AGGREGATE statement didn't specify an INIT support function — per the official guidance; handling a set-up argument must occur in an INIT function.
- A set-up argument passed to an aggregate with no INIT function registered, per the official guidance — the direct, only cause.
Solutions / Resolution
- Call the aggregate without a set-up argument, per the official guidance — the simpler option if the set-up argument isn't needed.
- Or implement a set-up argument, per the official guidance:
- Write an INIT support function that handles the set-up argument.
- Register the INIT function with CREATE FUNCTION.
- Drop the aggregate with DROP AGGREGATE.
- Redefine the aggregate with CREATE AGGREGATE, providing the INIT modifier.
Examples
Calling with a set-up argument but no INIT function
SELECT new_aggr(colA, 2) FROM some_table;
-- -9410: new_aggr has no INIT function registered
Corrected — calling without the set-up argument
SELECT new_aggr(colA) FROM some_table;
Diagnostic Checks
- Check the aggregate's CREATE AGGREGATE definition for an INIT modifier, and either drop the set-up argument from the call or add an INIT function and redefine the aggregate.
Related Errors / Related Topics
- -9403 — "The
modifier must be specified." The general required- modifier error this is a specific case of, for INIT with a set-up argument. - -9407 — "Set-up parameter to the aggregate
cannot contain non-group columns." A related set-up-argument error, on the argument's value rather than a missing INIT function.
The aggregate was called with a set-up argument but has no registered INIT function — drop the set-up argument, or add an INIT function and redefine the aggregate.