MainframeKit

-204

SQLSTATE 42704NEGATIVE SQLCODE

Db2 cannot find the object the statement names. Most often a wrong or missing qualifier (schema), or a table not yet created in this environment.

MOST LIKELY

The unqualified name was resolved with a different qualifier than expected (bind QUALIFIER, CURRENT SCHEMA or the authorization ID).

FIRST CHECK

Read the full name in the message, including the qualifier Db2 used.

TRY IT ▸

MainframeKit assistant

What it means

The statement refers to a table, view, alias, index, routine, package version or other object that does not exist in this Db2 subsystem under the name given. Db2 does not run the statement and returns -204 with SQLSTATE 42704. The message token shows the full name Db2 looked for, including the qualifier it used.

For a native SQL procedure the token can include the version. For COMMENT or DROP on a package, it means the version you asked for (or the version with no name, if you gave none) is not there.

Typical causes

  • The unqualified name was resolved with a different qualifier than expected (bind QUALIFIER, CURRENT SCHEMA or the authorization ID).
  • The table or view exists in test but was never created in this environment.
  • A typo in the object or schema name.
  • An alias or synonym the program relies on was dropped or never defined.
  • A stored procedure or function was not defined yet, or a package version name is wrong.

How to fix it

  1. Read the full name in the message, including the qualifier Db2 used.
  2. Check the catalog (SYSIBM.SYSTABLES, SYSROUTINES or SYSPACKAGE) for that exact name.
  3. If the qualifier is wrong, fix the bind QUALIFIER or SET CURRENT SCHEMA rather than the SQL.
  4. If the object is missing, ask the DBA to create it, then rerun.
  5. For a routine, define it with CREATE PROCEDURE or CREATE FUNCTION, then issue -START PROCEDURE so the new definition is used.
  6. For a package, name the right version on COMMENT or DROP with the VERSION clause.

Example

Illustrative only; names and values are invented.

DSNT408I SQLCODE = -204, ERROR:  TESTQ.CUSTMAST IS AN UNDEFINED NAME
DSNT418I SQLSTATE   = 42704 SQLSTATE RETURN CODE