Would this prevent the row from being read during the transaction?

Posted by acidzombie24 on Stack Overflow See other posts from Stack Overflow or by acidzombie24
Published on 2010-04-13T03:19:12Z Indexed on 2010/04/13 3:23 UTC
Read the original article Hit count: 207

Filed under:
|

I remember an example where reads in a transaction then writing back the data is not safe because another transaction may read/write to it in the time between. So i would like to check the date and prevent the row from being modified or read until my transaction is finish. Would this do the trick? and are there any sql variants that this will not work on?

update tbl set id=id where date>expire_date and id=@id

Note: date>expire_date happens to be my condition. It could be anything. Would this prevent other transaction from reading the row until i commit or rollback?

© Stack Overflow or respective owner

Related posts about sql

Related posts about concurrency