What it means
Db2 checks each name in a statement against the tables, views and variables that are in scope for that statement. A column in a SELECT or DELETE must come from a table in its FROM clause. A column in an INSERT, UPDATE or MERGE must belong to the target table. A qualified name must use a table designator that the statement defines. When a name fails these checks, Db2 stops the statement with -206 and the message names the object it could not resolve.
The same code also covers rules for SQL procedures and triggers, such as variables used outside their scope, and some features that need a higher APPLCOMPAT setting. The IBM page lists the full set of reasons; the points above are the ones met most often.
Typical causes
- A misspelled column name, or a name that exists in a different table.
- A table missing from the FROM clause of a SELECT or DELETE.
- A wrong qualifier, or a table designator the statement does not define.
- A correlated reference used where it is not allowed, such as in a grouping expression or in a subquery in ORDER BY.
- An INSERT or UPDATE column list that names a column the target table does not have.
- A trigger or SQL procedure variable used outside its scope, or a feature that needs a higher APPLCOMPAT setting.
How to fix it
- Make sure every table the statement takes columns from is in the FROM clause.
- If a correlated reference was intended, qualify the name with the correct table designator.
- Check each column name against the table definition, including the target table of INSERT, UPDATE and MERGE.
- Check the APPLCOMPAT setting if the statement uses a newer feature.
- Fix the name or the statement, then run it again.
Example
Illustrative only; names and values are invented.
SELECT CUST_NM, ORD_AMT FROM MYSCHEMA.ORDERS -- CUST_NM is not a column of ORDERS
SQLCODE = -206, object name CUST_NM