Re: Updating selected record

From: John DeSoi <desoi(at)pgedit(dot)com>
To: "Levente Lajko" <levente(dot)lajko(at)topline(dot)co(dot)uk>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Updating selected record
Date: 2005-02-09 06:42:14
Message-ID: BBEBBEE1-7A65-11D9-9303-000A95B03262@pgedit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Feb 8, 2005, at 9:05 AM, Levente Lajko wrote:

>  
>
> I have problem with a table from where I select specific field data
>
> SELECT filed1, field2 FROM tbl WHERE progress = 1 LIMIT 1
>
>  through a perl script or multiple instances of that script. The
> script sets the progress value of the progressed record to 0, so that
> other processes not to access that row. I presume I would need some
> locking solution, only I haven’t found the real one.
>
>  
>
> I hope somebody has a bright idea.

Maybe you are looking for SELECT FOR UPDATE as in

SELECT filed1, field2 FROM tbl WHERE progress = 1 LIMIT 1 FOR UPDATE;

This locks the row for the remainder of the transaction. See

http://www.postgresql.org/docs/8.0/interactive/sql-select.html#SQL-FOR-
UPDATE

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Antony Paul 2005-02-09 06:45:51 How to know a temp table exists ?
Previous Message Antony Paul 2005-02-09 06:13:20 Maximum length of a query