Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    44

    Unanswered: 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

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  3. #3
    Join Date
    Sep 2003
    Posts
    44
    Thanks Marcus!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •