Sometimes while running a COBOL-DB2 code one might get a -818 error on the first SQL statement that is executed in the code.
Idea for this KR triggered by Vignesh and Aalok. SQLCODE = -818, ERROR: The precompiler-generated Timestamp xxxxx in the load module is different from the the BIND TIMESTAMP yyyyy from the DBRM... Or in case you don't have the DB2 error handling routine (DSNTIAR is what displays the error messages in the spool), if you give a display of the SQLCODE you'll get a 81Q in the spool. To know what is the actual value for the display "81Q" we'll need to convert this (converting to hex will reveal the actual value). We can open any flat file in edit mode, type 81Q and then give the command HEX ON. The equivalent hex values would appear below 81Q and it will be F8F1D8 which is equal to -818 (D denotes a negative sign). -818 error signifies that the timestamp is different in the load module and the DBRM. Ideally both should be same; First question: From where does this timestamp come in the picture?
That's some of the theory on precompiling and binding; so why won't timestamps match? And how / where can we see them? We're running out of space in this edition; will be continued in the next...
Continuing with -818 sqlcode; We left off yesterday with the question, "Why won't the two timestamps match?" (i..e the DBRM and the load module's timestamps). Following are some possible reasons:
1.) We ran through the sequence of precompile, compile, link and bind once. Then again we ran only the precompile step. Here the DBRM will have a new timestamp while the load module will be old. 2.) The precompiler produces a DBRM and application program. We might have referred to a different PDS while compiling. 3.) Precompile, compile, link done but bind not done. Here the load module will have the latest timestamp while the plan is an old one (because binding wasn't done). 4.) We did everything but the precompiler didn't replace the existing DBRM. So the DBRM will have a old timestamp while the load module will have the new one.
Solutions?
What to do if we face problem number 4?
Well, next question is "that's fine but where can we see what this timestamp is"? Can we try to match the timestamps?"
More on that in the next edition;
We'll dig further into the DBRM and load module timestamps and internals of how all this works.
Some things we need to know:
Note: The timestamp is actually not in proper readable format (in the sense that we can't directly interpret the date/time from it). They are internal DB2 timestamps.
The timestamp will appear in 16 characters - this is the internal DB2 timestamp which we need. It might appear as: TIMESTAMP (from SYSDBRM): 17C3C25806552EE8
Note: The timestamp we get here has 16 hex characters. If in our query we didn't use the HEX function then we'll get eight characters on the screen. To be continued...(and do try out the query on your system);
Copyright © 2020 Sethu Subramanian All rights reserved. Reach me via email at ssbell @ gmail.com