Informix Error -11022: Degree of derived table does not match column list.
Cause and resolution
Degree of derived table does not match column list.
This Informix CLI error code is the same as SQLSTATE value 21S02. The following functions can return this error code: SQLExecDirect() and SQLPrepare().
The SQL statement contained a CREATE VIEW statement, but the number of column names for the view was not the same as the number of columns that the SELECT statement returns. Change the CREATE VIEW statement so that the number of column names is the same as the number of columns.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-11022 fires when a CREATE VIEW statement's explicit column-name list doesn't match the
number of columns its SELECT returns — per the official guidance, this is the same as
SQLSTATE value 21S02.
- A
CREATE VIEWcolumn-name list whose count doesn't equal theSELECT's returned column count, per the official guidance — the direct, only cause.
Solutions / Resolution
- Change the
CREATE VIEWstatement so the column-name count matches theSELECT's returned column count, per the official guidance.
Examples
A CREATE VIEW with mismatched counts
CREATE VIEW order_summary (order_id, total) AS
SELECT order_id, customer_id, total FROM orders;
-- -11022: 2 view columns for 3 selected columns
Corrected
CREATE VIEW order_summary (order_id, customer_id, total) AS
SELECT order_id, customer_id, total FROM orders;
Diagnostic Checks
- Count the view's column-name list and the
SELECT's returned columns, and confirm they match.
Related Errors / Related Topics
- -11021 — "Insert value list does not match column list." The same class of
count-mismatch error, for
INSERTrather thanCREATE VIEW.
A CREATE VIEW's column list doesn't match its SELECT's returned column count — align the two.