Informix Error -382
-382 Same number of columns must be specified for view and select clause.
In this VIEW statement, you have listed the names of the columns of the view. However, their number is different from the number of columns in the SELECT statement for the view. Check the punctuation of the two lists, and make sure that you have supplied a name for each item in the select list.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-382 fires when CREATE VIEW view_name (col1, col2, ...) explicitly lists column names, but the
count doesn't match the number of columns actually produced by the view's defining SELECT
statement.
- A view's explicit column-name list has more or fewer entries than the
SELECT's actual output columns — a simple counting mismatch. - A column added to or removed from the
SELECTduring maintenance without updating the view's explicit column-name list to match. - A punctuation mistake (a missing or extra comma) in either list, making the apparent count different from what was intended.
SELECT *used in the defining query, where the actual column count depends on the table's current schema and may not match an explicit view column list written earlier.
Solutions / Resolution
- Verify the punctuation in both lists, per the official guidance, and confirm each
SELECT-list item has exactly one corresponding column name. - Count both lists explicitly if the query is complex, rather than eyeballing them.
- Avoid
SELECT *in a view's defining query when an explicit column-name list is used — make the select list explicit too, so both lists can be kept in sync deliberately.
Examples
A mismatched column count
CREATE VIEW customer_summary (customer_id, name, region) AS
SELECT customer_id, name FROM customers;
-- -382: 3 names given, but the SELECT only produces 2 columns
Fix — match the counts:
CREATE VIEW customer_summary (customer_id, name) AS
SELECT customer_id, name FROM customers;
Adding a column consistently to both lists
CREATE VIEW customer_summary (customer_id, name, region) AS
SELECT customer_id, name, region FROM customers;
Diagnostic Checks
- Count the entries in the view's explicit column-name list.
- Count the columns actually produced by the
SELECT— expandSELECT *mentally (or literally) against the underlying table's current schema if used. - Compare the two counts directly rather than assuming they match.
Related Errors / Related Topics
- -317 — "The statement failed because you must have the same number of selected columns in
each UNION, INTERSECT, or MINUS query." A conceptually similar column-count-matching
restriction, in the
UNION/INTERSECT/MINUScontext instead. - -322 — "Cannot Alter view, Rename view or Create a trigger on a view." Another view-specific restriction, reinforcing the "drop and recreate" pattern relevant when fixing a view's column list.
Keep a view's explicit column-name list and its defining SELECT's column list in sync
deliberately — avoid SELECT * when an explicit column-name list is used, since the two need to
match exactly.