X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 700209DC97D for ; Mon, 19 Dec 2005 09:07:21 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33657-03 for ; Mon, 19 Dec 2005 09:07:24 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from TWMAIL.ESNCC.COM (static-66-173-159-28.t1.cavtel.net [66.173.159.28]) by postgresql.org (Postfix) with ESMTP id F1F519DC860 for ; Mon, 19 Dec 2005 09:07:18 -0400 (AST) Received: from spawar2i8uvlb9 ([150.125.117.63]) by TWMAIL.ESNCC.COM with Microsoft SMTPSVC(5.0.2195.6713); Mon, 19 Dec 2005 08:07:21 -0500 From: "Lane Van Ingen" To: Subject: How to Force Transactions to Process Serially on A Table Date: Mon, 19 Dec 2005 08:07:20 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181 Importance: Normal X-OriginalArrivalTime: 19 Dec 2005 13:07:21.0405 (UTC) FILETIME=[259CD6D0:01C6049D] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.224 required=5 tests=[AWL=0.224] X-Spam-Score: 0.224 X-Spam-Level: X-Archive-Number: 200512/155 X-Sequence-Number: 23697 I am using PL/SQL functions on Windows 2003, version 8.0.1. I have not used explicit PostgreSQL LOCKing before, but I need some advice on how properly to use some explicit locking. I think that duplicate key violations I am now getting are the result. I want to force transactions being used to update a table to be processed on a first-come, first-served basis. I want my Pl/sql function to execute to completion on each transaction before another starts. Need some advice on how to do this. From what I can read in the docs, it looks like I need to solve the problem by using the following, but doing so gives me an SPI_execution error: BEGIN; LOCK IN SHARE ROW EXCLUSIVE MODE; lock adns_report_hour_history in share row exclusive mode; INSERT INTO
VALUES ... - or - UPDATE
SET .... COMMIT; Will this make the next transaction wait until the previous transaction has completed? Do I need to set any config parameters? If you can include an actual code snippet in the response, it would help ...