Re: row-level locking

From: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
To: Markus Wagner <wagner(at)imbei(dot)uni-mainz(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: row-level locking
Date: 2003-04-01 11:24:10
Message-ID: 3E8976DA.5070803@mega-bucks.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-odbc

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Nigel J. Andrews 2003-04-01 11:36:23 Re: row-level locking
Previous Message drdave 2003-04-01 10:59:14 Re: How can I save/load all triggers/stored procedures from a file?

Browse pgsql-odbc by date

  From Date Subject
Next Message Nigel J. Andrews 2003-04-01 11:36:23 Re: row-level locking
Previous Message Hiroshi Inoue 2003-03-29 03:46:39 Re: Insert fails from VB only when table is empty...?