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 > Identity Column

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-17-05, 19:41
chas_dba chas_dba is offline
Registered User
 
Join Date: Sep 2003
Posts: 33
Unhappy Identity Column

We have Db2 v 7 on Z/os. We have a table with IDentity Column as a primary key and also FK for many other tables. We have loaded initial data with 200 records and then during testing there were some inserts incrimenting the IDentity column value to >300.
We wanted to refresh the data and loaded the data from another region around 350 records(loaded with values). During the testing we are getting duplicate record errors. I understand that the counter of Identity column is less than 350 and when trying to insert an new record, its getting duplicate rec viloation.

Question is How do i know the last inserted Identity column value.
Let me clarify here.. this is not in the same transaction or UOW. Can we get from Catalog tables..or else where. and i do not have pervious data as i load replaced it. Any help is greatly appreciated.
__________________
bs
Reply With Quote
  #2 (permalink)  
Old 12-18-05, 15:18
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,279
Quote:
We have loaded initial data with 200 records
Have you actually used LOAD to load those records ? You can only use IMPORT to "load" records, with an identity column. If you want to use LOAD, you should switch to sequences.

Stop the press: In the information I find on publib.boulder.ibm.com, it states that LOAD works with identity columns too, but I remeber it being an issue when we decided to use sequences of identity columns for our PK's. Perhaps this is no longer an issue for LUW DB2, but still for your version.
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
  #3 (permalink)  
Old 12-19-05, 04:58
juliane26 juliane26 is offline
Registered User
 
Join Date: Oct 2005
Posts: 109
are you using LOAD with REPLACE?
In that case for unique index violations all rows with the same index value will be skipped and not loaded, since DB2 does not decide for you which one to use.

In LOAD with RESUME the exisiting values will remain, the first one with a new index value will be loaded and only duplicates will be skipped.

Data is not logged as such for you to access, I am not sure which information you are looking for.

Just for RI sequences are not needed. Not available in z/OS V7 anyway.

How is your ID column defined that it does not support more than 350 entrys? Is it a generated column?

For Wim:
on z/OS some things are slightly different: unlike LUW a unique index is not automatically created when defining a primary key. Every Index - also the unique index to support a primary key - has to be created explicitely. So primary key definitions are mostly found only in RI constructs in parent tables.
And I can use load with generated identity columns, if that is what you mean. At least on z/OS it is no problem at all. (And I have no idea how this allone should be a reason to use sequences on LUW).
__________________
Juliane
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