MainframeKit

-904

SQLSTATE 57011NEGATIVE SQLCODE

Db2 could not use an object or resource, often a table space in a restricted state. The reason code and resource name tell you which and why.

MOST LIKELY

A table space or index stopped by an operator or DBA.

FIRST CHECK

Record reason code, resource type and resource name.

TRY IT ▸

Block size and space calculator

What it means

Db2 needed a resource and could not get it, so the statement failed. The SQLSTATE is 57011. Usually the resource is a database object — a table space, index space or partition — that is stopped, held by a utility, or in a pending state.

Read the three SQLERRMC tokens. The reason code (format 00Cxxxxx) says why; look it up in the Db2 codes documentation for your version. The resource type says what kind of object. The resource name usually has the form database.space, which you use in the next command.

Typical causes

  • A table space or index stopped by an operator or DBA.
  • A utility (REORG, LOAD, COPY, RECOVER) running or left in a stopped state.
  • A pending state after a utility or failure, such as recovery pending, check pending or copy pending, depending on the object and settings.
  • Pages in the logical page list after an I/O or failure problem.
  • Other resource limits defined at the site, shown by a different reason code.

How to fix it

  1. Record reason code, resource type and resource name.
  2. Look up the reason code meaning for your Db2 version.
  3. Issue -DISPLAY DATABASE(dbname) SPACENAM(spacename) RESTRICT (or ask the DBA) to see the object's status, such as STOP, UT, RECP, CHKP, COPY or LPL.
  4. Issue -DISPLAY UTILITY(*) to see whether a utility holds the object.
  5. Check the schedule and change records for maintenance at that time.
  6. The fix depends on the state and is normally a DBA action: let a running utility finish, terminate and clean up a failed one, run the recovery or check the state requires, or, once the DBA has confirmed the object is safe to use, start it with -START DATABASE. Starting does not clear pending states such as recovery-pending; those need the right utility. Do not use ACCESS(FORCE) as a shortcut. Once the object is available, rerun or restart the failed work. To turn the raw SQLCA into readable text, call DSNTIAR (DSNTIAC in CICS) with the SQLCA and a message buffer, or use GET DIAGNOSTICS to fetch MESSAGE_TEXT, RETURNED_SQLSTATE and DB2_RETURNED_SQLCODE. Either way, write the full message to the job log before the program ends.

Example

Illustrative only; names and values are invented.

DSNT408I SQLCODE = -904, ERROR:  UNSUCCESSFUL EXECUTION CAUSED BY AN
         UNAVAILABLE RESOURCE. REASON 00C900nn, TYPE OF RESOURCE
         00000200, AND RESOURCE NAME DBPAY01.TSPAY01
DSNT418I SQLSTATE   = 57011 SQLSTATE RETURN CODE