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;
The updated rows will be unlocked after a commit.