pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jean-Christian Imbeault <jc@mega-bucks.co.jp>
To: Markus Wagner <wagner@imbei.uni-mainz.de>
Cc: pgsql-general@postgresql.org
Subject: Re: row-level locking
Date: Tue, 01 Apr 2003 20:24:10 +0900
Message-ID: <3E8976DA.5070803@mega-bucks.co.jp> (raw)
References: <200304011336.41155.wagner@imbei.uni-mainz.de>

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




view thread (5+ messages)  latest in thread

Message-ID: <3E8976DA.5070803@mega-bucks.co.jp>
Permalink:  ../3E8976DA.5070803@mega-bucks.co.jp/
Also on:    postgresql.org/message-id/3E8976DA.5070803@mega-bucks.co.jp

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: jc@mega-bucks.co.jp, wagner@imbei.uni-mainz.de, pgsql-general@postgresql.org
  Subject: Re: row-level locking
  In-Reply-To: <3E8976DA.5070803@mega-bucks.co.jp>
  References: <200304011336.41155.wagner@imbei.uni-mainz.de> <3E8976DA.5070803@mega-bucks.co.jp>

* 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