X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3D8C54762F6 for ; Tue, 1 Apr 2003 06:32:29 -0500 (EST) Received: from ns.mega-bucks.co.jp (ns.mega-bucks.co.jp [219.118.175.241]) by postgresql.org (Postfix) with ESMTP id 221AA475F34 for ; Tue, 1 Apr 2003 06:32:25 -0500 (EST) Received: from mega-bucks.co.jp (dhcp4.mega-bucks.co.jp [192.168.255.103]) by ns.mega-bucks.co.jp (8.12.8/8.12.5) with ESMTP id h31BVtwe003723; Tue, 1 Apr 2003 20:31:55 +0900 Message-ID: <3E8976DA.5070803@mega-bucks.co.jp> Date: Tue, 01 Apr 2003 20:24:10 +0900 From: Jean-Christian Imbeault User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Markus Wagner Cc: pgsql-general@postgresql.org Subject: Re: row-level locking References: <200304011336.41155.wagner@imbei.uni-mainz.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-35.6 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/7 X-Sequence-Number: 40072 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