Re: SELECT FOR UPDATE

From: "Andrew G(dot) Hammond" <drew(at)xyzzy(dot)dhs(dot)org>
To: feblec(at)ig(dot)com(dot)br
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: SELECT FOR UPDATE
Date: 2002-03-12 17:46:22
Message-ID: 20020312174622.GB19889@xyzzy.dhs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, Mar 11, 2002 at 10:31:32PM -0300, feblec(at)ig(dot)com(dot)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(at)xyzzy(dot)dhs(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Eisentraut 2002-03-12 17:50:07 Re: in-date news items
Previous Message Ian Barwick 2002-03-12 17:28:08 Re: in-date news items