Informix Error -24302: Column (%s) not found in the source table.
Cause and resolution
Column (%s) not found in the source table.
This error is generated when a user tries to insert into the target table using a column from the target table. For example:
create table bonus (id int, bonus int); create table emp(id int, salary int);
MERGE INTO bonus D USING emp S ON D.id = S.id WHEN MATCHED THEN UPDATE SET bonus = bonus + salary*.01 WHEN NOT MATCHED THEN INSERT (D.id, D.bonus) VALUES (S.id, bonus);
This will generate the following error because in the VALUE clause the bonus column is not from the emp source table:
24302: Column (bonus) not found in the source table. Error in line 4 Near character position 66
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-24302 fires when a MERGE INTO statement's VALUES clause names a column that isn't from
the source table — per the official guidance, the VALUES clause must draw its values from
the source, not the target.
- A
VALUESclause naming a column from the target table (or elsewhere) instead of the source table, per the official guidance — the direct, only cause.
Solutions / Resolution
- Change the
VALUESclause to name only columns of the source table, per the official guidance.
Examples
A VALUES clause naming a target-table column
CREATE TABLE bonus (id INT, bonus INT);
CREATE TABLE emp (id INT, salary INT);
MERGE INTO bonus D
USING emp S ON D.id = S.id
WHEN MATCHED THEN UPDATE SET bonus = bonus + salary * .01
WHEN NOT MATCHED THEN INSERT (D.id, D.bonus) VALUES (S.id, bonus);
-- -24302: bonus belongs to the target table, not the source table emp
Corrected
MERGE INTO bonus D
USING emp S ON D.id = S.id
WHEN MATCHED THEN UPDATE SET bonus = bonus + salary * .01
WHEN NOT MATCHED THEN INSERT (D.id, D.bonus) VALUES (S.id, salary);
Diagnostic Checks
- Check every column named in the
MERGE'sVALUESclause, and confirm each belongs to the source table.
Related Errors / Related Topics
- -24300 — "Column (%s) not found in the target table." The mirror-image error, for
the
INSERTcolumn list naming a source-table column instead of a target-table one. - -24301 — "Table (%s) is not the target table." A related
MERGE-statement restriction, on theINSERTcolumn list's table qualifier. - -24303 — "Table (%s) is not the source table." A related
MERGE-statement restriction, on theVALUESclause qualifying with the wrong table name.
A MERGE's VALUES clause named a column that isn't from the source table — use only
source-table columns there.