Informix Error -2945: You may apply the after add, update, query, or remove commands to a table only -- not a column.
Cause and resolution
You may apply the after add, update, query, or remove commands to a table only -- not a column.
Aggregates (AVG, MIN, MAX, COUNT, TOTAL) can only be performed on fields that are associated with tables (not on DISPLAYONLY fields), and the tables must be listed in the opening command of the same control block. Revise the form specification, and recompile.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-2945's official description covers aggregate placement: per the official guidance, aggregates
(AVG, MIN, MAX, COUNT, TOTAL) can only be performed on fields associated with tables
(not DISPLAYONLY fields), and those tables must be listed in the opening command of the same
control block.
- An aggregate applied to a
DISPLAYONLYfield, per the official guidance — the first named cause. - An aggregate applied to a field whose table isn't listed in the enclosing control block's opening command, per the official guidance — the second named cause.
Solutions / Resolution
- Revise the form specification, and recompile, per the official guidance — either drop
DISPLAYONLYfrom the field if it genuinely needs aggregation, or add the field's table to the control block's opening command.
Examples
An aggregate on a DISPLAYONLY field
ATTRIBUTES
running_total = subtotal, DISPLAYONLY;
AFTER QUERY OF orders
LET total = AVG(running_total);
-- -2945: running_total is DISPLAYONLY
Corrected
ATTRIBUTES
subtotal = subtotal;
AFTER QUERY OF orders
LET total = AVG(subtotal);
Diagnostic Checks
- Check every aggregate expression's field for
DISPLAYONLYstatus and for whether its table appears in the enclosing control block's opening command.
Related Errors / Related Topics
- -2946 — "You may not calculate an aggregate on the display-only field name." A closely
related error covering the same restriction, phrased specifically around the
DISPLAYONLY-field case.
An aggregate function is applied to a DISPLAYONLY field, or to a field whose table isn't
listed in the control block — revise and recompile.