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 > Multiples Inserts at the same time

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-19-04, 16:49
ek1975 ek1975 is offline
Registered User
 
Join Date: Sep 2003
Posts: 44
Multiples Inserts at the same time

Application runs on z/OS, DB2 v7.1

Say there's a table A with column C1 with values 1A, 2A, 3A and column C1 allows duplicates and has no index

Now the next insert is going to be 4A, what if two users tried to insert 4A at the same time? and there should be only one row under 4A

I know for UPDATES we can use CURSORS with FOR UPDATE OF and prevent such a scenario, but what happens for INSERTS? (other than locking the table in exclusive mode)

if I do a prior SELECT with RR for value 4A, will it hold the lock until I explicitly release it after the insert?
Any ideas????
TIA
Reply With Quote
  #2 (permalink)  
Old 07-19-04, 17:16
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
If there should be only one row where the column value is 4A, then you need to create a unique index (or a Primary Key or Unique Constraint). You can lock existing rows, but that does not apply to inserts (unless the table or tablespace is locked).
__________________
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
  #3 (permalink)  
Old 07-20-04, 08:53
ek1975 ek1975 is offline
Registered User
 
Join Date: Sep 2003
Posts: 44
Thanks Marcus!
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