Informix Error -2946: You may not calculate an aggregate on the display-only field name.
Cause and resolution
You may not calculate an aggregate on the display-only field name.
Aggregates 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
-2946 fires when an aggregate function (AVG, MIN, MAX, COUNT, TOTAL) is applied to a
DISPLAYONLY field — per the official guidance, aggregates can only be performed on fields
associated with tables, and those tables must be listed in the opening command of the same
control block.
- An aggregate applied directly to a field marked
DISPLAYONLY, per the official guidance — the direct, only cause.
Solutions / Resolution
- Revise the form specification, and recompile, per the official guidance — apply the
aggregate to a table-associated field instead, or remove
DISPLAYONLYif the field genuinely needs to participate in the aggregate.
Examples
An aggregate on a named DISPLAYONLY field
ATTRIBUTES
line_total = subtotal, DISPLAYONLY;
INSTRUCTIONS
AFTER QUERY OF orders
LET grand_total = TOTAL(line_total);
END
END
-- -2946: line_total is DISPLAYONLY
Corrected
ATTRIBUTES
subtotal = subtotal;
INSTRUCTIONS
AFTER QUERY OF orders
LET grand_total = TOTAL(subtotal);
END
END
Diagnostic Checks
- Check the field named in the aggregate expression for
DISPLAYONLYstatus, and restructure the calculation to use table-associated fields instead.
Related Errors / Related Topics
- -2945 — its official title text is a site-side duplicate of -2944's title, but its own
description covers this same aggregate/
DISPLAYONLYrestriction, including the additional requirement that the field's table be listed in the control block's opening command.
An aggregate function is applied to a DISPLAYONLY field — apply it to a table-associated
field instead.