Informix Error -305
-305 Subscripted column column-name is not of type CHAR, VARCHAR, TEXT
nor BYTES.You may select substrings only from columns of the types mentioned. Review all uses of square brackets in this statement, and make sure that each follows the name of a column that has one of these types. If that is the case, verify that you are using the database you intended, and double-check the definition of the table. Possibly one of the columns in the table has been altered to use a different type.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-305 fires when square-bracket subscript notation (e.g. name[1,5], used to pull a substring or
byte range out of a column) is applied to a column whose type doesn't support it. Only CHAR,
VARCHAR, TEXT, and BYTES allow subscripting — numeric, date, and other data types don't.
- Subscripting a numeric, date, or other non-string/non-byte column — the direct cause.
- Confusing a column's actual type with its displayed/formatted value — a column that looks
like text in query output may actually be a
DATE,DATETIME, or numeric type underneath. - A schema change that altered a column's type since the query was originally written — a
CHAR/VARCHARcolumn changed to something else, silently breaking existing subscript usage. - Wrong database or table assumed — the query is subscripting a same-named column in a different table/database than intended, where that column has a different type.
Solutions / Resolution
- Verify each subscripted column's actual data type, per the official guidance, and confirm
it's one of
CHAR,VARCHAR,TEXT, orBYTES. - Confirm the correct database is in use — a same-named column can have a different type in a different database.
- Review the table definition for a recent, possibly unexpected type change if a previously-working subscript expression suddenly fails.
- If the goal is extracting part of a non-string value, convert it explicitly first (e.g.
TO_CHAR()for a date) before subscripting the resulting string.
Examples
Subscripting a non-string column
SELECT order_id[1,3] FROM orders;
-- -305: order_id is an INTEGER, not CHAR/VARCHAR/TEXT/BYTES
Fix — convert to a string first if extracting digits is genuinely the goal:
SELECT (order_id::VARCHAR(10))[1,3] FROM orders;
Checking a column's actual type before subscripting
SELECT c.colname, t.name AS type_name
FROM syscolumns c, systypes t
WHERE c.tabid = (SELECT tabid FROM systables WHERE tabname = 'orders')
AND c.coltype = t.type
AND c.colname = 'status';
Diagnostic Checks
- Look up the subscripted column's declared type in
syscolumns/systypesand confirm it'sCHAR,VARCHAR,TEXT, orBYTES. - Confirm the correct database context if the same column name exists in multiple databases with different types.
- Check for a recent
ALTER TABLE MODIFYon the column if this appeared on a previously working query.
Related Errors / Related Topics
- -293 — "IS [NOT] NULL predicate may be used only with simple columns." A related restriction on what kind of column expression certain operators can apply to.
- -219 — "Wildcard matching may not be used with non-character types." The closest sibling — another operator restricted to character-family types.
Subscript notation only works on CHAR, VARCHAR, TEXT, and BYTES — convert other types to
one of these explicitly before attempting to extract a substring or byte range.