UPDATE w/ subselect doing locking

From: David Ford <dford(at)erisksecurity(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: UPDATE w/ subselect doing locking
Date: 2001-11-14 07:34:51
Message-ID: 3BF21E9B.4060106@erisksecurity.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Would someone mind setting my head on straight with a proper query
please. Here is my table and the query I have thusfar. I need it to
match and update specifically only the string I specify for the regex.

bluelist=> select * from spamcontrol;
id | logical group | count | add time | added
by | regex | comment
----+---------------+-------+-------------------------------+----------------+-----------------------------------------------+---------
| | 5 | 2001-11-12 00:09:41.326116-05 |
208.179.59.203 | MERCATI FINANZIARI |
| | 5 | 2001-11-12 00:10:24.292267-05 |
208.179.59.203 | setup fees |

bluelist=> UPDATE spamcontrol SET count=foo.count+1 FROM (SELECT count
FROM spamcontrol WHERE regex='setup fees' FOR UPDATE) as foo;

How do I get it to only update that one row?

Thank you,
David

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Antonio Fiol Bonnín 2001-11-14 08:17:59 Re: [GENERAL] Storing a tree
Previous Message Command Prompt, Inc. 2001-11-14 07:30:39 Re: Vacuuming - how often?