Informix Error -9407: Set-up parameter to the aggregate <aggregate-name> cannot </aggregate-name> contain non-group columns.
Cause and resolution
Set-up parameter to the aggregate <aggregate-name> cannot </aggregate-name> contain non-group columns.
If the user-defined aggregate has been defined with a set-up argument, the second argument of this aggregate must be either a constant or one of the columns in the GROUP BY clause of your query.
For example, the following two statements are valid:
SELECT new_aggr(colA, 2) FROM some_table
SELECT new_aggr(colA, colB) GROUP BY colB FROM some_table
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-9407 fires when a user-defined aggregate's second (set-up) argument is neither a constant nor a column in the query's GROUP BY clause — per the official guidance.
- A set-up argument referencing a non-group column, per the official guidance — the direct, only cause.
Solutions / Resolution
- Use a constant as the set-up argument, per the official guidance — for example,
SELECT new_aggr(colA, 2) FROM some_table. - Or use one of the columns in the query's GROUP BY clause, per the official
guidance — for example,
SELECT new_aggr(colA, colB) GROUP BY colB FROM some_table.
Examples
A set-up argument using a non-group column
SELECT new_aggr(colA, colC) FROM some_table GROUP BY colB;
-- -9407: colC isn't a constant or in GROUP BY
Corrected
SELECT new_aggr(colA, colB) FROM some_table GROUP BY colB;
Diagnostic Checks
- Check whether the aggregate's set-up argument is a constant or matches a GROUP BY column, and correct it if not.
Related Errors / Related Topics
- -9410 — "User-defined aggregate
has two arguments but no INIT function specified." A related set-up-argument error, on a missing INIT function rather than an invalid argument value.
The aggregate's set-up argument wasn't a constant or a GROUP BY column — use one or the other.