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 DA5403A4AEA for ; Fri, 19 Nov 2004 12:59:27 +0000 (GMT) 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 87302-10 for ; Fri, 19 Nov 2004 12:59:19 +0000 (GMT) Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89]) by svr1.postgresql.org (Postfix) with ESMTP id BB0C93A4B03 for ; Fri, 19 Nov 2004 12:59:20 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-31.mail.demon.net with esmtp (Exim 4.42) id 1CV8MK-000F50-4h; Fri, 19 Nov 2004 12:59:30 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id AF77C1780A; Fri, 19 Nov 2004 12:59:02 +0000 (GMT) Message-ID: <419DEE1B.6010805@archonet.com> Date: Fri, 19 Nov 2004 12:59:07 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: abief_ag_-postgresql@yahoo.com Cc: pgsql-sql@postgresql.org Subject: Re: transactions in functions, possible bug or what I'm doing References: <20041119115231.27648.qmail@web13924.mail.yahoo.com> In-Reply-To: <20041119115231.27648.qmail@web13924.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/192 X-Sequence-Number: 19511 Riccardo G. Facchini wrote: > Why does select test_without_transaction(); > return this info: > "ABCD" (as should be) > > and select test_with_transaction(); > returns this error? > > ERROR: SPI_prepare() failed on "start transaction" > CONTEXT: PL/pgSQL function "test_with_transaction" line 6 at SQL > statement > > I've been investigating the matter in the doc I have, but to no avail. > google was not helpful either. The function-call is already within a transaction (every command is), and you can't have nested transactions in 7.4. You can have what are called "savepoints" in version 8.0 though, which lets you trap errors and rollback to a named (saved) point in your function. -- Richard Huxton Archonet Ltd