Informix Error -308
-308 The statement failed because corresponding column data types must be
compatible for each UNION, INTERSECT, or MINUS query.All rows produced in a union, intersect or minus of SELECT statements must have the same format, so the corresponding columns for each UNION, INTERSECT or MINUS statement must have the same data type or compatible data types. Two data types are compatible if you can convert one of them into the other; for example, INT and FLOAT are compatible data types because you can convert INT values to FLOAT values. In the current statement, a column in the second or subsequent SELECT statement does not agree with the corresponding column in a preceding SELECT statement.
Review and compare all the SELECT statements. Check each point at which one statement selects a column that is not identical to a column in the preceding SELECT statement. If the column data types do not match, then one type must be convertible to the other type.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-308 fires when combining multiple SELECT statements with UNION, INTERSECT, or MINUS and
a column in one statement's select list doesn't have a compatible data type with the
corresponding column (by position) in another statement's select list. Every row produced by the
combined query must have a consistent column format — matching or convertible types (INTEGER
and FLOAT, for instance) — column by position, not by name.
- Corresponding select-list columns with fundamentally incompatible types — e.g. a character
column paired positionally with a
DATEor numeric column that can't be implicitly converted. - Column order mismatch — the columns are individually fine, but they're in a different
order across the combined
SELECTstatements, so incompatible types end up paired positionally even though compatible ones exist elsewhere in each list. - A schema change to one of the underlying tables (a column's type changed) since the combined query was written, breaking a previously-compatible pairing.
- Combining queries against genuinely different tables/entities where the natural column
types just don't line up, without an explicit
CAST/conversion.
Solutions / Resolution
- Review every
SELECTstatement in the combined query, per the official guidance, and confirm each column matches or converts cleanly to its positional counterpart in the others. - Reorder the select lists if the mismatch is due to columns simply being in different positions across the statements, rather than genuinely incompatible types.
- Add an explicit
CAST/conversion to bring a column's type in line with its counterpart when an implicit conversion isn't available. - Check for a recent column-type change on one of the underlying tables if a previously working combined query started failing.
Examples
Mismatched column order across UNION branches
SELECT customer_id, name, order_date FROM current_orders
UNION
SELECT order_date, customer_id, name FROM archived_orders;
-- -308: column order differs, pairing incompatible types positionally
Fix — align the column order across both statements:
SELECT customer_id, name, order_date FROM current_orders
UNION
SELECT customer_id, name, order_date FROM archived_orders;
Explicit conversion for a genuinely different type
SELECT customer_id, CAST(notes AS VARCHAR(255)) FROM current_orders
UNION
SELECT customer_id, comments FROM archived_orders;
-- assuming notes/comments differ in type (e.g. TEXT vs VARCHAR),
-- an explicit CAST brings them in line
Diagnostic Checks
- List each
SELECTstatement's column types in order, and compare them positionally across every branch of theUNION/INTERSECT/MINUS. - Check for a recent schema change on any underlying table if this appeared on a previously working query.
Related Errors / Related Topics
- -201 — "A syntax error has occurred." The general SQL-parsing-error family this fits into.
Column compatibility across UNION/INTERSECT/MINUS is positional, not by name — check column
order first, then actual type compatibility.