Informix Error -254
-254 Too many or too few host variables given.
The number of host variables that you named in the INTO clause of this statement does not match the number of columns that you referenced in the statement.
Locate the text of the statement (in a PREPARE or DECLARE statement) and verify the number of placeholders. Then review the list in the INTO clause to see which item or items are incorrect.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-254 is the embedded-SQL (ESQL/C) counterpart to -236's count-mismatch family — the number of
host variables named in an INTO clause doesn't match the number of columns actually referenced
in the statement.
- A mismatch between the number of selected columns and the number of host variables listed
in the
INTOclause — fewer or more than needed. - A
SELECTlist edited (columns added or removed) without correspondingly updating theINTOclause's host variable list. - A typo or miscount when writing the
INTOclause manually. - Using
SELECT *without tracking the exact current column count, then providing a host-variable list that no longer matches after a later schema change.
Solutions / Resolution
- Locate the statement (in a
PREPAREorDECLARE) and verify the number of placeholders, per the official guidance. - Review the
INTOclause's item list to find and correct the specific mismatch. - Prefer explicit column lists over
SELECT *in embedded SQL, to avoid this fragility after future schema changes. - When a
SELECTlist changes, update the correspondingINTOclause in the same change — treat them as a matched pair that must move together.
Examples
The straightforward mismatch
EXEC SQL SELECT customer_id, name, email
INTO :cid, :cname
FROM customer WHERE customer_id = 1;
/* -254: 3 columns selected, only 2 host variables provided */
Fix:
EXEC SQL SELECT customer_id, name, email
INTO :cid, :cname, :cemail
FROM customer WHERE customer_id = 1;
A schema change breaking a previously-matching count
/* Originally 3 columns, 3 host variables — worked fine */
EXEC SQL SELECT id, name, status INTO :id, :name, :status FROM orders WHERE id = :oid;
/* After a later ALTER TABLE adds a column and this statement was
changed to SELECT * without updating the host variable list */
EXEC SQL SELECT * INTO :id, :name, :status FROM orders WHERE id = :oid;
/* -254: orders now has 4 columns */
Diagnostic Checks
- Count the columns in the
SELECTlist against the host variables in theINTOclause. - Review recent schema or select-list changes if this appeared unexpectedly on a statement that used to work.
Related Errors / Related Topics
- -236 — "Number of columns in INSERT does not match number of VALUES." The closest
conceptual sibling — the same count-mismatch theme, applied to
INSERT/VALUESrather thanSELECT/INTO. - -201 — "A syntax error has occurred." The general SQL-parsing-error family this fits into.
Treat the SELECT list and its INTO clause as a matched pair — any change to one requires an
equivalent change to the other.