Re: Locking row - Mailing list pgsql-sql

From Larry Rosenman
Subject Re: Locking row
Date
Msg-id 023e01c64485$4be7f630$0a0a0a0a@aus.pervasive.com
Whole thread Raw
In response to Locking row  (Flavio Suguimoto <flavio.suguimoto@pragyatechnologies.com>)
Responses Re: Locking row
List pgsql-sql
Flavio Suguimoto wrote:
> Hi all,
> 
> I need to mark a row with a value in a column, but first i need to
> select the first row without this mark. But in some concurrents cases
> i mark the row twice. How can i lock the row to avoid others session
> get it? 
> 
> TABLE TICKET
> TICKET_NUMBER | MARK
>         00001 |    1
>         00002 |    0
> 
> I need to select the first row with 0 in MARK column and then mark it
> with 1.


look at the FOR UPDATE in the select docs.



-- 
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 512-248-2683                 E-Mail: ler@lerctr.org
US Mail: 430 Valona Loop, Round Rock, TX 78681-3893



pgsql-sql by date:

Previous
From: Flavio Suguimoto
Date:
Subject: Locking row
Next
From: Bryce Nesbitt
Date:
Subject: Advice on setting up a grid like view for spreadsheet users