"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Wed, May 26, 2021, 08:20 Yambu <hyambu@gmail.com> wrote:
>> UPDATE table1 set status_id=13 WHERE id= ( SELECT id FROM table2 where
>> status_id=1 LIMIT 1 *FOR UPDATE*) RETURNING id into v_id;
> I don't think there is a point in saying for update when you are executing
> an update command.
The FOR UPDATE is in a subselect, so what it's doing is locking
rows of table2. That seems fairly sensible if what you want to
do is make sure those rows don't change before the UPDATE
commits.
regards, tom lane