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 B566152848 for ; Mon, 4 Jul 2005 08:14:57 -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 88393-09 for ; Mon, 4 Jul 2005 11:14:46 +0000 (GMT) Received: from mail.idilis.net (mail.idilis.net [217.156.85.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9412E5284F for ; Mon, 4 Jul 2005 08:14:45 -0300 (ADT) Received: from [82.76.228.65] (helo=adi) by mail.idilis.net with asmtp id 1DpOuS-0006NR-00; Mon, 04 Jul 2005 14:14:44 +0300 Date: Mon, 04 Jul 2005 14:14:29 -0700 To: pgsql-sql@postgresql.org Subject: Help on Procedure running external function 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 Message-ID: User-Agent: Opera M2/7.54 (Win32, build 3929) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.86 tagged_above=0 required=5 tests=AWL, DATE_IN_FUTURE_06_12 X-Spam-Level: X-Archive-Number: 200507/11 X-Sequence-Number: 21989 Hello, I have a 'big' problem: I am trying to run from a procedure a function witch generate a new document number (max from table +1 ) and after to insert a document with this number, but the function returns me the same number each time because the tranzaction is not finished and the inserts are not commited and of course the next document number is the same. ... for ... loop nr=get_me_next_number(params); insert into table values (nr,...) end loop ... ... error inserting in table .. primary_key nr ..... Is any way in making the external function to 'know' that I inserted another row but this insert is in a tranzaction that is not finish yet ? ar onother solution ? for now I 'solved' by asking for a nr once and generate myself next number (+1) but this is not a correct solution (in this time somebody else could insert a document with the same nr as the procedure ) thank you, Adi -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/