If I may....
> I know that we should have declared the FK
> on the database but it is too late now. I want to understand the issue
> better. Isn't there a "maintenance task" in DB2 that scans through
> tables and does some optimization on identity columns or something
> like that?
You can export and load the data, then you can do SET INTEGRITY with
exception table, this is how you can Identify exception rows:
http://publib.boulder.ibm.com/infocenter/db2luw/v8/topic/com.ibm.db2.udb.doc/adm
in/c0004593.htm
Example 5: Check integrity for T1 and T2, and put the violating rows
into exception tables E1 and E2.
SET INTEGRITY FOR T1, T2 IMMEDIATE CHECKED
FOR EXCEPTION IN T1 USE E1,
IN T2 USE E2
> We had a problem earlier and it could be connected to this
> one. It was about restoring from backup. After a successful restore we
[quoted text clipped - 4 lines]
> cache of DB2 but they wasn't clear about it also nobody cared because
> we could solve it with a simple script.
How you perform the backup and restore (full backup, incremental...)
>> You will need to track which SQL is updating the FK (or could it be that
>> your PK's are updated ??? Or your "real PK" is changed (since you were
[quoted text clipped - 5 lines]
> me that there isn't anything in the code that could possibly update a
> FK or a PK.
Just the same DB2 cannot possibly update a PK or FK on its own.
> Anyway the client program functions fine at many customers
> with various versions of DB2 Express-C. Changing keys also would be
[quoted text clipped - 5 lines]
> tables and does some optimization on identity columns or something
> like that?
No, DB2 has three intersections with IDENTITY columns as far as table
content is concerned:
1. INSERT. Where is looks up the next value in the SEQUENCE, assuming
that it's not GENERATED BY DEFAULT where a vlaue may have been provided
2. LOAD. Same thing, but depending on which action DB2 may re-use
idnetity values provided by the source file, ignore the source and
produce new ones, or simply produce new ones.
3. UPDATE SET DEFAULT
You can ask DB2 to reissue a new value by SETing the identity column
to DEFAULT
That's it. no maintenance code... Once INSERT, UPDATE, LOAD is done teh
rest of DB2 has no knowledge of a column being identity.
> We had a problem earlier and it could be connected to this
> one. It was about restoring from backup. After a successful restore we
[quoted text clipped - 4 lines]
> cache of DB2 but they wasn't clear about it also nobody cared because
> we could solve it with a simple script.
When you restore a database the identity columns will pick up with teh
next batch of cached values.
Let's say teh last CAHCE of 20 (default) was: 21-40.
You last INSERT produced 35 before backup.
After restore the next value produced will be 41 because the remaining
cache 36-40 was lost. The same happens on db2stop or when DB2 crashes.
Now, if you "restore" your database using db2look (re-issuing the DDL!)
then DB2 will run the ORIGINAL CREATE TABLE statement and indeed start
with whatever the start value was.
If you then load data using IDENTITY OVERRIDE, then you can see what you
saw.
Anyway, since your client team swears that no LOAD was done, no UPDATE T
SET pk = DEFAULT was done either we are still stuck with mystery ....
Cheers
Serge
PS: Do you have triggers?

Signature
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
stegze - 20 May 2008 09:53 GMT
I'll be allowed to do some live tests soon then I'll check everything
you suggested. It seems now that something on the server machine is in
conflict with DB2. I don't know if it could be the cause of the data
change but it is disturbing. Unfortunately it is a Debian Linux and it
isn't supported by IBM so it could be anything. Thank both of you for
all your comments and help.
Serge Rielau - 20 May 2008 12:14 GMT
> I'll be allowed to do some live tests soon then I'll check everything
> you suggested. It seems now that something on the server machine is in
> conflict with DB2. I don't know if it could be the cause of the data
> change but it is disturbing. Unfortunately it is a Debian Linux and it
> isn't supported by IBM so it could be anything. Thank both of you for
> all your comments and help.
I simply don't buy any low-level corruption. These things typically
truly look like garbage when they occur.
What you see is "too smart" for a random act.
Cheers
Serge

Signature
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Mark A - 20 May 2008 12:29 GMT
> I'll be allowed to do some live tests soon then I'll check everything
> you suggested. It seems now that something on the server machine is in
> conflict with DB2. I don't know if it could be the cause of the data
> change but it is disturbing. Unfortunately it is a Debian Linux and it
> isn't supported by IBM so it could be anything. Thank both of you for
> all your comments and help.
It sounds like the problem is related to something like a export and
subsequent import of data, with the identity columns getting regenerated,
instead of using the original values. You need to provide more detail about
all backup/restore and export/import/load operations that were done on the
database.
stegze - 27 May 2008 15:33 GMT
> It sounds like the problem is related to something like a export and
> subsequent import of data, with the identity columns getting regenerated,
> instead of using the original values. You need to provide more detail about
> all backup/restore and export/import/load operations that were done on the
> database.
There wasn't any import, load or restore except the one we did when we
initially set up the database. The server was in production state only
for about three weeks now. Last weekend we reinstalled the Linux
system and DB2 as well. For two days everything was fine and today the
data corruption happened again. The current version of the client
program works fine at many locations with the same DB2 version and all
of the servers are installed and taken care of by the same guy. I can
only think of a sabotage activity of an employee at my customer's
office. It doesn't make sense any other way. Thanks for your efforts.