Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    20

    Unanswered: Transaction and read values

    Hello,
    I have following situation:
    1st thread: start transaction, update some values in table (with (rowlock))
    2nd thread: starts select for this record.

    I have tried some possibilities with SET TRANSACTION ISOLATION LEVEL but noone is suitable for me. I would like during such running transaction to have possibility to read but the OLD values (last commited).

    Am I able to reach this behaviour with some setting of locks, transaction level?

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    you can use the NOLOCK hint on your 2nd thread but beware of dirty reads.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Dec 2003
    Posts
    20
    The problem is that in this case I will receive new value which is not commited yet.

    1st thread:
    select rftime from bobj with (nolock) where intid = 2

    -> retuns e.g. 10

    2nd thread:
    begin transaction
    update bobj set rftime=20 where intid = 2

    1st thread:
    select rftime from bobj with (nolock) where intid = 2
    -> retuns 20 !

    I would like to receive 10 here and no waiting for transaction end from 2nd thread with select statement. with update it should wait...
    Last edited by Sladky; 05-26-06 at 12:23.

Posting Permissions

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