Informix Error -678
-678 Invalid subscript for column column-name in check constraint.
A subscripted column in a check constraint has subscripts outside the bounds of the column. Check that the bounds specified in the subscripted column do not exceed the maximum length of the column. If you know the table name of the column, use the following subquery to query the system-catalog tables to find out the maximum length of the column:
SELECT collength FROM syscolumns WHERE colname = 'column-name' AND tabid = (SELECT tabid FROM systables WHERE tabname = 'table-name')
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-678 fires when a CHECK constraint's expression subscripts a column with bounds outside the
column's actual maximum length — the CHECK-constraint-specific analog of -607's subscript
bounds rule.
- A subscript's upper bound exceeding the column's declared length, per the official guidance — the direct, only cause.
- A
CHECKexpression written before the column's length was finalized, left unchanged after the column's declared length was later reduced.
Solutions / Resolution
- Check that the subscript bounds don't exceed the column's maximum length, per the official guidance.
- Look up the column's actual maximum length, per the official guidance's documented query:
SELECT collength FROM syscolumns WHERE colname = 'column-name' AND tabid = (SELECT tabid FROM systables WHERE tabname = 'table-name'); - Adjust the subscript bounds in the
CHECKexpression to fit within that length.
Examples
Exceeding the column's length
CREATE TABLE documents (title VARCHAR(50), CHECK (title[1,100] != ''));
-- -678: 100 exceeds title's declared length of 50
Looking up the actual length, then correcting
SELECT collength FROM syscolumns
WHERE colname = 'title'
AND tabid = (SELECT tabid FROM systables WHERE tabname = 'documents');
-- returns 50
CREATE TABLE documents (title VARCHAR(50), CHECK (title[1,50] != ''));
Diagnostic Checks
- Query
syscolumnsfor the column'scollength, per the official guidance's documented query, and compare against the subscript bounds used in theCHECKexpression.
Related Errors / Related Topics
- -607 — "Text/Byte subscript error." The general subscript-syntax rule this
CHECK-specific case is a variant of, forTEXT/BYTEsubscripts outside a check-constraint context. - -676 — "Invalid check constraint column." A related
CHECKrestriction, about column scope rather than subscript bounds. - -677 — "Check constraint cannot contain subqueries or procedures." A related
CHECKrestriction, about disallowed expression types.
Look up the column's actual collength via syscolumns before setting subscript bounds in a
CHECK expression.