What it means
Every table, view, alias and sequence in Db2 has a two-part name, a schema and an object name, such as PAYPROD.EMP_HIST. Programs often leave the schema off and write just EMP_HIST. Db2 then fills in the schema. For static SQL in a package it uses the QUALIFIER bind option, or the package owner if no QUALIFIER was given. For dynamic SQL it normally uses the CURRENT SCHEMA special register, which starts out equal to CURRENT SQLID.
If no object exists with the resulting full name, Db2 returns -204 and puts the name it looked for in SQLERRMC. Compare that name with the one you expected.
Static SQL can get -204 at bind time or at run time. With VALIDATE(BIND), the bind fails and no new package is made. With VALIDATE(RUN), the bind ends with warnings and Db2 checks the name again each time the statement runs.
Common causes
- The package was bound with a QUALIFIER or owner from another environment. EMP_HIST resolves to PAYTEST.EMP_HIST in production, or the other way round.
- The table, view or alias was never created in this subsystem, or it was dropped for a change and not yet recreated.
- The object name is misspelled in the program.
- A dynamic SQL user, for example in SPUFI or QMF, has a different CURRENT SQLID or CURRENT SCHEMA from the one the query was written for.
- An alias still exists but the table behind it was dropped. Db2 keeps the alias, and using it gives -204 for the missing table.
- A NEXT VALUE FOR expression names a sequence that isn't in that schema.
How to find the problem
- Read the name in the DSNT408I message or SQLERRMC. It is fully qualified, so you can see which schema Db2 used.
- Look the object up with
SELECT CREATOR, NAME, TYPE FROM SYSIBM.SYSTABLES WHERE NAME = 'EMP_HIST'. TYPE shows a table (T), view (V) or alias (A), and CREATOR shows which schemas have one. - For static SQL, check QUALIFIER and OWNER for the package in SYSIBM.SYSPACKAGE.
- For dynamic SQL, run
SELECT CURRENT SQLID, CURRENT SCHEMA FROM SYSIBM.SYSDUMMY1in the same session. - Look at the bind job output. A VALIDATE(RUN) bind lists a warning for the same name, which tells you the problem was there before the program ran.
How to fix it
- Rebind the package with the right qualifier for this environment, for example
REBIND PACKAGE(PAYCOLL.PAYUPD1) QUALIFIER(PAYPROD). - For dynamic SQL, issue
SET CURRENT SCHEMA = 'PAYPROD'before the query, or qualify the name in the statement. - Create the missing object if the name is right, or create an alias that points to the right table.
- Fix a misspelled name in the program, then precompile, compile and bind again.
- If a bind failed with -204, no new package was made. Bind again after the fix, or the new load module will get -805 at run time.
What it looks like
PAYUPD1 - OPEN CSR-HIST FAILED DSNT408I SQLCODE = -204, ERROR: PAYTEST.EMP_HIST IS AN UNDEFINED NAME DSNT418I SQLSTATE = 42704 SQLSTATE RETURN CODE