Re: Atomic/locked "allocation" of table row? - Mailing list pgsql-novice

From Rodrigo De León
Subject Re: Atomic/locked "allocation" of table row?
Date
Msg-id 1186371869.486283.231530@o61g2000hsh.googlegroups.com
Whole thread Raw
In response to Atomic/locked "allocation" of table row?  (Sten Daniel Soersdal <netslists@gmail.com>)
List pgsql-novice
On Aug 5, 9:02 pm, netsli...@gmail.com (Sten Daniel Soersdal) wrote:
> Help?

SELECT FOR UPDATE:

http://www.postgresql.org/docs/8.2/static/sql-select.html#SQL-FOR-UPDATE-SHARE

-- Example --
CREATE OR REPLACE FUNCTION FOO(MYSECRET TEXT) RETURNS INT AS
$$
DECLARE
  U INT;
BEGIN
  SELECT USERNAME
  INTO U
  FROM TUNNEL
  WHERE PASSWORD IS NULL LIMIT 1 FOR UPDATE;
  UPDATE TUNNEL SET PASSWORD = MYSECRET WHERE USERNAME = U;
  RETURN U;
END;
$$ LANGUAGE PLPGSQL;


pgsql-novice by date:

Previous
From: Chirag Patel
Date:
Subject: clustering and denormalizing with PostgreSQL?
Next
From: "Demian Quinonez"
Date:
Subject: restoring with sql script