Re: row-level locking - Mailing list pgsql-general

From Jean-Christian Imbeault
Subject Re: row-level locking
Date
Msg-id 3E8976DA.5070803@mega-bucks.co.jp
Whole thread Raw
In response to row-level locking  (Markus Wagner <wagner@imbei.uni-mainz.de>)
List pgsql-general
Markus Wagner wrote:
>
> We found a short description for the "SELECT FOR UPDATE" statement:
> "perform exclusive locking of selected rows"
>
> Now my question: Is this a good method for our purpose?

I had the same question not too long ago.

It's a great method.

It doesn(t have to be in an explicit transaction as all postgres sql
statements are executed in their own transactions. The row will be
locked until your transaction (implicit or explicit) is commited or
rolled-back.

 From a VB application the tricky part will be finding out how to start
an explicit transaction and then committing it.

For example I found out that in Java:

SELECT ... FOR UPDATE;
[do some stuff on the row]

Did not lock the rows as expected since Java automatically "committed"
the implicit transaction around the "SELECT ... FOR UPDATE" statement.

I had to turn off the default transaction commital of the JDBC, execute
my query/statement and *then* explicitly commit the transaction.

VB and ODBC might need something similar.

HTH,

Jean-Christian Imbeault


pgsql-general by date:

Previous
From: Markus Wagner
Date:
Subject: row-level locking
Next
From: "Nigel J. Andrews"
Date:
Subject: Re: row-level locking