Monday, June 24, 2013

About DB2 Consistency Token(CONTOKEN), DB2 SQL ERROR -805 and -818

What is contoken or consistency token in DB2?
 If we remember during precompilation process, the SQL part and COBOL part  are separated.While doing so, compiler engraves a time stamp to each part, so that later they can identify each other. at run time. This time stamp is what we call Contoken or consistency token
We get SQL code of -818 when the Consistency Token placed by DB2 precompilation Step  does not match between the DBRM and the Load Module.
80N or -805 is what we get when the DBRM or Package is not found in Plan which we used in JCL.

Steps to find out the contoken and verify if both are same??
We can go to QMF or run the below query

We fetch the HEX value for the contoken.Otherwise we wont be able to see the value,if fetched normally.
This Fetches the program-name, its contoken, bind time and the DBRM Library order by latest bind time.


we can get the same Contoken (with out using the above query also) by looking into the DBRM library for the program.
Open the DBRM Library and give the command HEX ON
Position of contoken in DBRMLIB
Look for 25 to 32nd position in the first line. That will show the contoken.


Next Step 2:
Remember the Date and Time part of Contoken are swapped in Loadlib, you need to split the above contoken into two halves of 8 characters each and swap their positions like below:
Taking the above example, contokens are
1st Half : 18DAE169
2nd Half: 1F0420A5

Swapping and joining them results in

Now go to the LOAD MODULE library and search for it like
 f x'1F0420A518DAE169'

 You should be able to see this. Else There is a contoken mismatch.Rebind again or recompile to get rid of this freaking problem. -:)
Note:  F x 'search-string' . Here x implies the search string in quotes is hex value.



  1. First time I commented in a blog! I really enjoy it. You have an awesome post. Please do more articles like this. I'm gonna come back surely. God bless.


  2. Having 10+ years exp, I never know how to look for inconsistency in DBRM & Loadlib. Only used to follow the -818 and recompiled/re-binded the package. Appreciate your efforts. May God Bless You.. :-)

  3. Too good. Thanks for informative read.

  4. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in TECHNOLOGY , kindly contact us
    MaxMunus Offer World Class Virtual Instructor led training on TECHNOLOGY. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Saurabh Srivastava
    Skype id: saurabhmaxmunus
    Ph:+91 8553576305 / 080 - 41103383

  5. This is an excellent tip and know-how for a DB2 z/OS programmer Thanks a lot.