Update more than one row atomically

后端 未结 3 1855
囚心锁ツ
囚心锁ツ 2021-01-13 18:03

I need to execute a select and then update some of the rows in the ResultSet in an atomic way.

The code I am using looks like (simplified):



        
3条回答
  •  抹茶落季
    2021-01-13 18:43

    What happens if any other process has changed the database row that you are updating via updateRow() ? Is there any way to lock the rows in the ResultSet ?

    In Oracle, you can kinda mark certain rows for update by issuing the following SQL.

    select cola, colB from tabA for update;
    

    The next transaction/thread/app that tries to update this row will get an exception. see this for more details -- http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4530093713805

提交回复
热议问题