X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 42DCA52913 for ; Tue, 5 Jul 2005 09:39:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82512-06 for ; Tue, 5 Jul 2005 12:39:31 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.197.194]) by svr1.postgresql.org (Postfix) with SMTP id 9998D52896 for ; Tue, 5 Jul 2005 09:39:30 -0300 (ADT) Received: (qmail 12786 invoked by uid 500); 5 Jul 2005 12:39:48 -0000 Date: Tue, 5 Jul 2005 07:39:48 -0500 From: Bruno Wolff III To: Zac Cc: pgsql-sql@postgresql.org Subject: Re: Help on Procedure running external function Message-ID: <20050705123948.GB11379@wolff.to> Mail-Followup-To: Bruno Wolff III , Zac , pgsql-sql@postgresql.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/27 X-Sequence-Number: 22005 On Tue, Jul 05, 2005 at 13:47:24 +0200, Zac wrote: > I think you should use 'FOR UPDATE' clause in your first "select": > > select into vnrBon maxnrbon+1 from MagMaxNrBon where magazie = > dsgroup.magazie_implicita_lansare FOR UPDATE; > > In this way you lock the rows eventually returned and no one can update > them (or select them "for update") until your transaction finished. That doesn't work because you don't lock rows which aren't in the table yet. You need to use a lock table instead.