Received: from mercurio.feedback.net.ar (mercurio.feedback.net.ar [200.69.65.8]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f9AD45n92044 for ; Wed, 10 Oct 2001 09:04:05 -0400 (EDT) (envelope-from gperosio@dd.com.ar) Received: from io.feedback.net.ar (io.feedback.net.ar [200.69.65.39]) by mercurio.feedback.net.ar (8.11.0/8.11.0/Debian 8.11.0-6) with ESMTP id f9AD3ct03496 for ; Wed, 10 Oct 2001 10:03:38 -0300 Subject: SELECT FOR UPDATE CLAUSE From: Gerardo Perosio To: pgsql-sql@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Evolution/0.13 (Preview Release) Date: 10 Oct 2001 10:06:01 -0300 Message-Id: <1002719161.525.45.camel@io.feedback.net.ar> Mime-Version: 1.0 X-Archive-Number: 200110/139 X-Sequence-Number: 5094 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~