How to unlock a row if i use FOR UPDATE clause

99封情书 提交于 2019-12-11 04:23:05

问题


In procedure if we use FOR UPDATE clause, it will lock particular row and allow only one client to update whereas other client can only fetch data in the same row at that time.

My question is when will it unlock the row, what should we do to unlock the row while writing procedure? Take this example here I'm using FOR UPDATE clause for client_count, when ll it unlock that particular row in this procedure.

create or replace PROCEDURE newprocedur(inMerid IN VARCHAR2,outCount OUT NUMBER) AS 
CURSOR c1 IS 
  select CLIENT_COUNT 
    from OP_TMER_CONF_PARENT 
   where MER_ID = inMerid 
   FOR UPDATE OF CLIENT_COUNT;
BEGIN
  Open c1;
  loop
    fetch c1 into outCount;
    exit when c1%NOTFOUND;
    outCount:=outCount+1;
    update OP_TMER_CONF_PARENT 
       set CLIENT_COUNT = outCount 
     where current of c1;
  end loop;
  close c1;
END;

回答1:


The updated rows will be unlocked after a commit.



来源:https://stackoverflow.com/questions/13151701/how-to-unlock-a-row-if-i-use-for-update-clause

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!