Db2 SQLCODE

SQLCODE -818: Timestamp mismatch between program and DBRM

SQLCODE -818 (SQLSTATE 51003) means the consistency token in the running load module doesn't match the one Db2 holds for the bound DBRM. The program and its bound SQL came from different precompiles.

Also written as SQL -818, SQLCODE=-818, SQLCODE = -818, db2 -818, sqlstate 51003, SQL0818N, db2 timestamp conflict.

What it means

The Db2 precompiler writes a consistency token, normally based on the time of the precompile, into two places. One copy goes into the changed source and ends up in the load module. The other goes into the DBRM, which is bound later. At run time Db2 compares them. If they differ, the load module and the bound SQL weren't built from the same precompile, and running it could execute the wrong SQL. Db2 stops it with -818. The message shows both tokens in hex and the DBRM name.

On current Db2 for z/OS, programs run through packages, and Db2 uses the token to find the package in the first place. So a mismatch there normally appears as -805 reason 03 instead. -818 is more typical of Db2 for LUW, and of older plans that had DBRMs bound straight into them, which Db2 10 and later no longer allow. The causes and the cure are the same as for -805.

Common causes

  • The program was precompiled and compiled again, but the new DBRM wasn't bound.
  • The DBRM was bound, but the matching compile and link-edit didn't run, or went to a different load library.
  • The job runs a copy of the load module from another library in the STEPLIB or JOBLIB concatenation.
  • A promotion copied the DBRM from one precompile and the load module from another.

How to find the problem

  1. Note both tokens and the DBRM name in the message. The first token comes from the load module and the second from the bound DBRM.
  2. Compare PCTIMESTAMP (precompile time) and BINDTIME for the package in SYSIBM.SYSPACKAGE with the load module's link-edit date.
  3. Check the STEPLIB and JOBLIB order to see which copy of the module ran.
  4. Check your change management records for the last precompile, compile and bind of the program.

How to fix it

  • Precompile, compile, link-edit and bind together from the same source, then run again.
  • If the load module is the right one, bind the DBRM from its precompile with BIND PACKAGE ... ACTION(REPLACE). A REBIND won't help, because it reuses the SQL already stored for the old package.
  • If the package is the right one, link-edit or restore the matching load module.
  • Fix the load library concatenation so test and production copies can't mix.
  • Promote DBRMs and load modules as one unit through your change tool.

What it looks like

DSNT408I SQLCODE = -818, ERROR:  THE PRECOMPILER-GENERATED TIMESTAMP 18B2C4F00A1E3D27 IN THE
         LOAD MODULE IS DIFFERENT FROM THE BIND TIMESTAMP 18B2A9C5122F0B44 BUILT FROM THE
         DBRM INVCALC
DSNT418I SQLSTATE   = 51003 SQLSTATE RETURN CODE

Questions

What's the difference between -805 and -818?

Both say the program and its bound SQL don't match. -805 means Db2 found no package with the program's token at all. -818 means Db2 found the bound SQL, but its token differs from the load module's.

Will REBIND fix -818?

No. REBIND uses the SQL already stored for the package, so the token stays the same. You need to bind from the right DBRM, or run the right load module.

What does the LEVEL precompiler option do?

It lets you set the consistency token yourself instead of using the precompile time. Most shops avoid it, because a fixed token can let a changed program run against old SQL.