If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Timestamp conflict problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-11-08, 02:38
lekhrajm lekhrajm is offline
Registered User
 
Join Date: Dec 2007
Posts: 8
Timestamp conflict problem

Hi,
I am getting "A timestamp conflict occurred. SQLSTATE=51003" problem.

I wrote a C program to query a db2 database.
input : alias, userid, passwd
purpose: connect to the given database and fire some create/select/insert
queries
Problem : When database is on local box, it works fine. but if its not on local box, it gives "A timestamp conflict occurred. SQLSTATE=51003
SQLSTATE 51003: Consistency tokens do not match"

Any Ideas..

LekhRaj
Reply With Quote
  #2 (permalink)  
Old 01-11-08, 05:26
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
I assume that you use embedded SQL and not something like CLI/ODBC? You precompile the C source code, correct?

What happens in such a case is the following: The DB2 precompiler extracts all SQL statements and replaces them with regular C function calls into libdb2. The SQL statements are bundled into a bind file. In order to use those SQL statements, you must bind the bind file to a database, which creates a package. Naturally, DB2 must ensure that the package in the database matches the (compiled) C code. If it doesn't, you would run into problems because, for example, you connect to the wrong database, DB2 wouldn't return all columns in a query that the program expects, you would use completely wrong queries and tables, etc. In order to ensure the consistency between the precompiled C code and the package, DB2 uses timestamps that are generated at precompilation time and stored in the bind file (package) as well as the precompiled code. (You can actually use your own consistency tokens using the LEVEL option for the DB2 precompiler.)

Now, when you work with the database against which the precompile was run, things just work because DB2 already created the package as part of the precompilation. With another database, you don't have the package (or in the wrong version) in the database and you will the mentioned error. What you have to do there is to bind the bind file (option BINDFILE for the DB2 precompiler to generate this file) to each database against which your application should run. Note that I'm talking about "databases" here and not "local box"/"remote box" because local/remote has nothing to do with this.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 01-14-08, 02:39
lekhrajm lekhrajm is offline
Registered User
 
Join Date: Dec 2007
Posts: 8
Thanks KNUT for reply...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On