Can I lock rows in a cursor if the cursor only returns a single count(*) row?
Posted
by RenderIn
on Stack Overflow
See other posts from Stack Overflow
or by RenderIn
Published on 2010-06-18T15:14:02Z
Indexed on
2010/06/18
15:23 UTC
Read the original article
Hit count: 181
I would like to restrict users from inserting more than 3 records with color = 'Red'
in my FOO table. My intentions are to A) retrieve the current count so that I can determine whether another record is allowed and B) prevent any other processes from inserting any Red records while this one is in process, hence the for update of
.
I'd like to do something like:
cursor cur_cnt is
select count(*) cnt from foo
where foo.color = 'Red'
for update of foo.id;
Will this satisfy both my requirements or will it not lock only the rows in the count(*) who had foo.color = 'Red'
?
© Stack Overflow or respective owner