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 5CC9D52808 for ; Tue, 5 Jul 2005 09:52:48 -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 83034-09 for ; Tue, 5 Jul 2005 12:52:41 +0000 (GMT) Received: from mail.idilis.net (mail.idilis.net [217.156.85.2]) by svr1.postgresql.org (Postfix) with ESMTP id 81674528C7 for ; Tue, 5 Jul 2005 09:52:40 -0300 (ADT) Received: from [82.76.228.65] (helo=adi) by mail.idilis.net with asmtp id 1Dpmui-0003rE-00; Tue, 05 Jul 2005 15:52:36 +0300 To: "Bruno Wolff III" , Zac Cc: pgsql-sql@postgresql.org Subject: Re: Help on Procedure running external function References: <20050705123948.GB11379@wolff.to> Message-ID: Date: Tue, 05 Jul 2005 15:52:21 -0700 From: Din Adrian Organization: OMC Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <20050705123948.GB11379@wolff.to> User-Agent: Opera M2/7.54 (Win32, build 3929) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.93 tagged_above=0 required=5 tests=AWL, DATE_IN_FUTURE_06_12 X-Spam-Level: X-Archive-Number: 200507/28 X-Sequence-Number: 22006 I am sorry but: the table is TEMPORARY ... I don't need to do any lock on it .... (eventualy I should do a lock on the table where I want to insert the documents - the MagMaxNrBon is only a temp table used for storing the max document nr for each user's setings in this transaction - I did that temp table instead of running always the return_next_number function (the problem I postit first) - I run once the function for every user's settings - get the max doc free number, store in the temp table, do the insert in onother table and next time I get this number and raise by 1 instead of running again the get_next_number function (because as I said - it give the same max number (the insert into table is not 'visible') )) ... as I said it's 'solved' ... thank you, Adrian Din On Tue, 5 Jul 2005 07:39:48 -0500, Bruno Wolff III wrote: > 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. > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings > -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/