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 > DB2 Sequence

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-06-11, 09:17
pkumar210 pkumar210 is offline
Registered User
 
Join Date: Jul 2011
Posts: 9
Question DB2 Sequence

Hello Everyone,

I have a wierd problem which I am currently facing with my sequences.
I have a an 2 ITIC (integration tool) mapping which is running in parallel and updating/creating records in a table XYZ which has a primary uniuqe key ID which is generated through a sequence.

Now out of the 2 ITIC's (lets say ITIC A and ITIC B) one is creating problem with the sequences it is generating the sequence which is already generated by the other and then the other ITIC is giving sql exception (duplicate unique value)
I am not sure if it is because the 2 ITIC 's are running in parallel and updating/creating records in the same table/attributes.

Please help with this
Thanks
Piyush
Reply With Quote
  #2 (permalink)  
Old 09-06-11, 09:45
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
i could think of situation where in a same UOW we select from sequence and insert in table
it might be better to commit the increment of sequence asap and not to wait for other operation like insert to occur.
otherwise you could define the column in the table as identity and value would be assigned by table-handler and not sequence...
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #3 (permalink)  
Old 09-06-11, 11:29
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
It is not clear if you are using Sequences or Identity columns, but in either case you do not need to commit to reserve them. Once they are obtained, no one else can use them, and if you rollback there will be a gap in the sequence.

On the other hand, if you are using some homegrown next-available-number table, instead of sequences or identity columns, then you could have a problem with commits.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #4 (permalink)  
Old 09-06-11, 12:01
pkumar210 pkumar210 is offline
Registered User
 
Join Date: Jul 2011
Posts: 9
Thanks for the quick reply

I am using Sequence here and not the Identity coloumns.
The problem is 2 parallel ITIC runs both access same sequence and both getting the same generated number from sequence.
Reply With Quote
  #5 (permalink)  
Old 09-06-11, 12:05
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
What version of DB2 is it ? I suggest that you raise a PMR.
DB2 Sequences are not supposed to work that way.

As Marcus said, incrementing of sequences do not wait for the transaction to commit.

A basic question: How do you know they are the same sequence ? Are the schemas same too? Can you check in the db2 catalog ?
Also, are you sure that the applications do not share the very same sequence number ?

select * from syscat.sequences where seqname='seqence name'


Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
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