Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2012
    Posts
    16

    Question Unanswered: Updating a single row by one user, transactions

    Hi,

    I'm trying change a field value of a table to indicate that only one user has been updated a row. After set a value of this field in a single row another user cannot to do the same operation. How can i check if only a user has been updated this row ?
    At moment I'm starting a transaction and doing it:

    START TRANSACTION;

    Code:
    SELECT INCFLAG FROM NEW TABLE(
    update
    MYTABLE
    set
    INCFLAG = INCFLAG+1,
    USERSET = USERNAME
    where
    MYTABLE.INCFLAG = 0
    )
    After I will check if INCFLAG > 1.
    If INCFLAG > 1 then rollback transaction else I'm commit.
    To get the user of operation I'm using the USERSET field.
    What I'm doing is correct? I'm using "read commited" isolation.

    Thanks.

  2. #2
    Join Date
    Nov 2011
    Posts
    334
    From your update statement ,i cant see any possiblility that incflag will > 1。
    because of the predicate MYTABLE.INCFLAG = 0。
    by the way,as for as i kown db2 for luw has no isolation level called "read commited"?
    There are "RR, RS,CS,UR"。
    Maybe it is the isolation level of oracle。

  3. #3
    Join Date
    Mar 2012
    Posts
    16

    Talking

    I'm sorry but I am a new DB2 user.
    I'll find more information about the DB2 isolation levels.
    Thanks for your reply!

Posting Permissions

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