Simple Mainframe Universe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Db2 Troubleshooting


SQLCODE -904 unavailable resource

SQLCODE -904: unavailable resource — DB2 could not get something it needs (dataset, page set, log).

What it means

  • After every EXEC SQL, DB2 returns a SQLCODE: 0 means success, +100 means no row found, and negative values mean an error.

Common causes

  • Dataset for the table space is not available.
  • Another system component holds the resource.
  • Log dataset space issue.

How to diagnose

  • Read SQLERRM: it names the unavailable resource.
  • -DISPLAY DATABASE(*) SPACENAM(*) for object state.
  • Check MVS for dataset enqueue or allocation problems.

How to fix it

  • Make the dataset available (vary online, fix allocation).
  • Resolve the competing holder.
  • For log issues, involve the DBA immediately.

Example: Read SQLERRM first

* SQLERRM names the exact resource, e.g. DSNDBC.PAYDB.TS1. * Start there, not with the SQL text.

SQLERRM is the fastest pointer to the real problem.

Interview tip

  • Q: How would you troubleshoot a SQLCODE -904 unavailable resource in production?
  • A: I would check the SQLCODE and SQLERRM immediately after the failing statement, reproduce in SPUFI, then apply the specific fix.

Prevention checklist

  • Always check SQLCODE after every EXEC SQL statement.
  • Log the SQLCODE, SQLSTATE and failing statement for support.




© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant