Re: SELECT FOR UPDATE - Mailing list pgsql-sql

From Andrew G. Hammond
Subject Re: SELECT FOR UPDATE
Date
Msg-id 20020312174622.GB19889@xyzzy.dhs.org
Whole thread Raw
In response to SELECT FOR UPDATE  (feblec@ig.com.br)
List pgsql-sql
On Mon, Mar 11, 2002 at 10:31:32PM -0300, feblec@ig.com.br wrote:
> Any example ?  Or this is select not implemented ?  ( V7.2 )

It's implemented, and has been for a while.  Here's a trivial example.

BEGIN;
SELECT * FROM stuff WHERE stuff_id = '1' FOR UPDATE;
-- row 1 is now locked (exclusive), so we can do what needs doing
UPDATE stuff SET something = 'whatever' WHERE stuff_id = '1';
COMMIT;

This is covered in the manual, see
http://www2.ca.postgresql.org/users-lounge/docs/7.2/postgres/sql-select.html

I don't mind answering newbie questions like this in the appropriate
forum (pgsql-novice list for example).  In the future please at least
check the manual or give it a try before posting. :)

--
Andrew G. Hammond  mailto:drew@xyzzy.dhs.org  http://xyzzy.dhs.org/~drew/
56 2A 54 EF 19 C0 3B 43 72 69 5B E3 69 5B A1 1F              613-389-5481
5CD3 62B0 254B DEB1 86E0  8959 093E F70A B457 84B1
"To blow recursion you must first blow recur" -- me

pgsql-sql by date:

Previous
From: "Andrew G. Hammond"
Date:
Subject: Re: in-date news items
Next
From: Peter Eisentraut
Date:
Subject: Re: in-date news items