pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gerardo Perosio <gperosio@dd.com.ar>
To: pgsql-sql@postgresql.org
Subject: SELECT FOR UPDATE CLAUSE
Date: 10 Oct 2001 10:06:01 -0300
Message-ID: <1002719161.525.45.camel@io.feedback.net.ar> (raw)

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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




Message-ID: <1002719161.525.45.camel@io.feedback.net.ar>
Permalink:  ../1002719161.525.45.camel@io.feedback.net.ar/
Also on:    postgresql.org/message-id/1002719161.525.45.camel@io.feedback.net.ar

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gperosio@dd.com.ar
  Subject: Re: SELECT FOR UPDATE CLAUSE
  In-Reply-To: <1002719161.525.45.camel@io.feedback.net.ar>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox