SELECT FOR UPDATE CLAUSE - Mailing list pgsql-sql

From Gerardo Perosio
Subject SELECT FOR UPDATE CLAUSE
Date
Msg-id 1002719161.525.45.camel@io.feedback.net.ar
Whole thread Raw
List pgsql-sql
Hi all.
I have a problem with an application written in php.
I need to lock a record for update, and I use the following transaction:

BEGIN WORK;

//row1 is an indexed field
SELECT row1, row2 from table1 where row3 = NULL order by row1 FOR UPDATE
limit 1;
//fetch row1 in $myvar
UPDATE table1 set row3 = now() where row1 = $myvar;
...
COMMIT WORK;

When I have more than one transaction (multiuser environment), the
record obtained is a null row for the rest of transaction, this is
logic, because now this record there isn't row3 = NULL . My idea is
fetch any row than row3 = NULL.
I think that, If I fetch 64 rows whit limit 64 (max number of concurrent
transactions in postgresql.conf) and iterate throw this, or, loop until
the fetch for $myvar not equal null.
Any other idea.

Thanks in advance.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Despues de tres dias sin programar,la vida se torna sin sentido."
-- Geoffrey James, "The Tao of Programming"

Gerardo Perosio
Operaciones - Desarrollos Digitales
http://www.dd.com.ar
(+54-11)6667-5700
Talcahuano 446 7* - Bs.As. Argentina
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



pgsql-sql by date:

Previous
From: Allan Engelhardt
Date:
Subject: Re: ROUND function ??
Next
From: Wilkinson Charlie E
Date:
Subject: VACUUM VERBOSE ANALYZE locking up?? Please help!