What is a Consistency Token in DB2?

We remember that during the precompilation process, DB2 separates the SQL statements from the COBOL (or host language) code. At this stage, the compiler assigns a timestamp, known as the Consistency Token (Contoken), to both the DBRM (Database Request Module) and the Load Module.

At runtime, DB2 uses this token to ensure that the DBRM matches the Load Module being executed.

If the DBRM or Package is missing in the Plan specified in JCL, you will see SQLCODE -805 (or 80N).


How to Find and Verify a Contoken

Step 1: Query the Package Table

You can retrieve the Contoken using QMF or by running this SQL. We will check with a random program and its contoken value

SELECT NAME, HEX(CONTOKEN), BINDTIME, PDSNAME
FROM SYSIBM.SYSPACKAGE
WHERE NAME = 'PROGRAM-NAME'
ORDER BY BINDTIME DESC;

  • HEX(CONTOKEN) converts the token into a readable hex value.
  • The query above shows the program name, Contoken, bind time, and DBRM library, ordered by the most recent bind taking ‘PROGRAM-NAME’ as dummy.

Alternatively, you can also check directly in the DBRM Library:

  1. Open the DBRM dataset.
  2. Enter the command HEX ON.
  3. Look at positions 25 to 32 in the first line — this is the Contoken.


Step 2: Match with Load Module

In the Load Module, the date and time portions of the Contoken are swapped. To compare:

  1. Split the Contoken (from DBRM) into two halves of 8 characters each.
    • Example: 18DAE1691F0420A5
    • 1st half → 18DAE169
    • 2nd half → 1F0420A5
  2. Swap the halves and rejoin them: 1F0420A518DAE169
  3. Go to the Load Library and search for it: F X'1F0420A518DAE169'
  • If found → The Contokens match.
  • If not → There’s a mismatch. You’ll need to Rebind or Recompile the program to fix it.

Leave a comment

Discover more from DBzTech-Technology Dossier

Subscribe now to keep reading and get access to the full archive.

Continue reading