Re: UPDATE w/ subselect doing locking

From: David Ford <david(at)blue-labs(dot)org>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: UPDATE w/ subselect doing locking
Date: 2001-11-15 17:12:19
Message-ID: 3BF3F773.6060400@blue-labs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yes, I know that works. I want to figure out how to use SELECT ... FOR
UPDATE with UPDATE because I will have a need to lock these certain rows
and do a bit more than just 'count'.

Thank you,
David

Marc SCHAEFER wrote:

>On Wed, 14 Nov 2001, David Ford wrote:
>
>>bluelist=> UPDATE spamcontrol SET count=foo.count+1 FROM (SELECT count
>>FROM spamcontrol WHERE regex='setup fees' FOR UPDATE) as foo;
>>
>
>You want to increment atomically the count of the row where regex is setup
>fees ?
>
>UPDATE spamcontrol SET count = count + 1 WHERE regex = 'setup fees';
>

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jacob Vennervald Madsen 2001-11-15 17:26:06 Re: Postgres+Delphi
Previous Message Francisco Reyes 2001-11-15 17:07:56 Re: pgsql and large tables