Informix Error -615: TEXT and BYTE columns are not allowed in this expression.
Cause and resolution
TEXT and BYTE columns are not allowed in this expression.
This statement uses an aggregate function, such as COUNT, SUM, MIN, MAX, or AVG, but applies it to a column that has the BYTE or TEXT data type. This action is not supported.
Review the use of each aggregate function to make sure that it is not applied to a BYTE or TEXT column.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-615 fires when an aggregate function (COUNT, SUM, MIN, MAX, AVG) is applied to a
TEXT/BYTE column — per the official guidance, none of these aggregates are defined for these
types.
SUM/AVGapplied to aTEXT/BYTEcolumn, meaningless since these types don't support arithmetic at all.MIN/MAXapplied to aTEXT/BYTEcolumn, meaningless since these types have no defined lexical order to compare by, the same underlying restriction behind -612/-613/-614.COUNT(column)applied to aTEXT/BYTEcolumn specifically (rather thanCOUNT(*)), when only the row count — not anything about the BLOB values themselves — was actually needed.
Solutions / Resolution
- Review each aggregate function's argument to confirm none is applied to a
TEXT/BYTEcolumn, per the official guidance. - Use
COUNT(*)instead ofCOUNT(text_column)if only a row count was needed, not anything about the BLOB values. - Aggregate a derived, comparable column instead, if some property of the BLOB content genuinely needs to be summarized — extract that property into a separate column at insert/update time, and aggregate that column instead.
Examples
The disallowed attempt
SELECT MAX(content) FROM documents;
-- -615: content is TEXT
Using COUNT(*) instead
SELECT COUNT(*) FROM documents WHERE content IS NOT NULL;
Diagnostic Checks
- Check every aggregate function call in the statement for a
TEXT/BYTEargument, and replace it withCOUNT(*)or a derived comparable column as appropriate.
Related Errors / Related Topics
- -544 — "Cannot have aggregates within aggregates." A related aggregate-usage restriction.
- -595 — "Incorrect use of an aggregate function." A related restriction on where aggregates can appear at all, rather than what type they can be applied to.
No aggregate function is defined for TEXT/BYTE — use COUNT(*) for a row count, or
aggregate a derived comparable column for anything about the BLOB content itself.