When embedded SQL fails before “real” data work, you often have a bind packaging problem. DB2 for z/OS -805 means the runtime cannot find the package the plan needs. -818 means the load module and the bound DBRM are from different precompiles. This page covers both in depth.
Plans point at packages through a package list (PKLIST). Each package is identified by location, collection, DBRM/package name, and a consistency token (precompile fingerprint). -805 is “search failed.” -818 is “we found something to compare and the fingerprints disagree.” Both use SQLSTATE 51xxx (invalid application state / prepare environment).
| SQLCODE | SQLSTATE | Meaning |
|---|---|---|
| -805 | 51002 | Package not found in plan (reason-code) |
| -818 | 51003 | Load module timestamp ≠ DBRM/bind timestamp |
IBM: PACKAGE NAME location-name.collection-id.dbrm-name.consistency-token NOT FOUND IN PLAN plan-name. REASON reason-code. Collection-id is blank if CURRENT PACKAGESET was blank for local execution.
There is no package list for the plan. Query SYSIBM.SYSPACKLIST for the plan; if no rows, BIND/REBIND with PKLIST and the needed entries.
Possible BIND issues:
Possible application issues:
Search found candidate entries but not the package. Same causes as 02, plus: the DBRM version was never bound (no package with that consistency token), or the wrong load module version is running. Bind the DBRM of the version you execute into the collection, or run the load that matches the bound token.
Package does not exist at the remote location-name. Query SYSPACKAGE at that location. Native SQL procedures that SET PACKAGESET / PACKAGE PATH / CONNECT, or that touch remote objects, may need additional BIND COPY packages after regeneration.
123456789101112131415-- Query 2: package list for the plan SELECT LOCATION, COLLID, NAME FROM SYSIBM.SYSPACKLIST WHERE PLANNAME = 'plan-name'; -- Query 3: CURRENTSERVER on the plan SELECT NAME, CURRENTSERVER FROM SYSIBM.SYSPLAN WHERE NAME = 'plan-name'; -- Query 4: matching package (add COLLID predicate when known) SELECT COLLID, NAME, HEX(CONTOKEN), VERSION FROM SYSIBM.SYSPACKAGE WHERE NAME = 'dbrm-name' AND HEX(CONTOKEN) = 'consistency-token';
System action: statement cannot be processed. SQLSTATE 51002. Do not “fix” this by ignoring SQLCODE—you must align PKLIST, collection, version, and connection.
IBM: THE PRECOMPILER-GENERATED TIMESTAMP x IN THE LOAD MODULE IS DIFFERENT FROM THE BIND TIMESTAMP y BUILT FROM THE DBRM z. Timestamps x and y are Db2-internal (not wall clock). z is the DBRM name.
At precompile, Db2 puts timestamp y in the DBRM and timestamp x in the application’s SQL parameter list. Bind stores the DBRM timestamp. At run time Db2 compares x for the statement with y from DBRM z. If they differ, the DBRM and the program are not from the same precompile.
Typical cases IBM lists:
Programmer response: bind again using the DBRM that matches the load module. SQLSTATE 51003.
1234567Correct pipeline (one generation): 1. Precompile PROG → PROG.DBRM + modified source 2. Compile + link → PROG load module (contains timestamp x) 3. BIND PACKAGE/PLAN with THAT PROG.DBRM (timestamp y) 4. Run the load from step 2 under the plan from step 3 -818 if step 3 used yesterday's DBRM with today's load (or vice versa).
Package VERSION helps when multiple consistency tokens coexist. -805 reason 03 often means you deployed a new load without binding the new DBRM into the collection your PKLIST searches. In change control, treat “promote load library” and “BIND PACKAGE COPY/REPLACE into collection X” as one change set. Splitting them across weekends is a classic Monday-morning -805/-818 storm.
-807 is package not enabled for a connection type/name (ENABLE/DISABLE on bind). Different SQLSTATE and fix (REBIND ENABLE, or check SYSPKSYSTEM). If CICS works but batch fails (or the reverse), compare ENABLE settings before you rebuild DBRMs.
Some older materials mention “+818” style notes; on z/OS the error for timestamp mismatch is negative -818. Always confirm the sign in SQLCA.
Applications that SET CURRENT PACKAGESET to switch collections must use a collection that appears in the plan’s PKLIST (or is otherwise searchable per your bind design). A typo in the host variable, or an encoding mismatch on the SET, yields -805 with reason text that looks like “package missing” when the real bug is “wrong collection.” Dump the special register after SET and compare to SYSPACKLIST.
Distributed packages and regenerated native SQL procedures add extra bind steps (BIND COPY, remote SYSPACKAGE). When -805 reason 04 appears, verify the package at the remote location-name, not only at the local catalog. Local Query 4 with a location-qualified FROM clause is IBM’s recommended check.
For -805: plan name, full package name from the message (location.collection.dbrm.token), reason-code, CURRENT PACKAGESET value, and whether the failing SQL is local or remote. Attach SYSPACKLIST and HEX(CONTOKEN) query output. For -818: precompile job name, DBRM library member timestamp/name, BIND job that produced the package, and load module library used at run time. That set usually separates “forgot to bind” from “bound the wrong generation” in one pass.
-805 is “the librarian cannot find the book your library card says you may borrow” (wrong shelf list, wrong collection, or never catalogued). -818 is “you brought a book cover from Monday and pages from Tuesday—the stamps do not match, so you cannot check out.”
1. SQLCODE -805 means:
2. Reason-code 01 on -805 typically means:
3. SQLCODE -818 means:
4. A common cause of -818 is:
5. How do -805 and -818 differ?