Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id A51959FC1E1 for ; Fri, 22 Jun 2007 10:25:00 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 12494-02 for ; Fri, 22 Jun 2007 10:24:52 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id D7B0D9FC227 for ; Fri, 22 Jun 2007 10:24:51 -0300 (ADT) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 23C3C763D7; Fri, 22 Jun 2007 14:24:50 +0100 (BST) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 0B70C274120; Fri, 22 Jun 2007 14:24:50 +0100 (BST) Message-ID: <467BCDA1.9070606@archonet.com> Date: Fri, 22 Jun 2007 14:24:49 +0100 From: Richard Huxton User-Agent: Thunderbird 2.0.0.0 (X11/20070326) MIME-Version: 1.0 To: Bart Degryse Cc: pgsql-sql@postgresql.org Subject: Re: Transactions and Exceptions References: <467BE1BB.A3DD.0030.0@indicator.be> In-Reply-To: <467BE1BB.A3DD.0030.0@indicator.be> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/173 X-Sequence-Number: 28663 Bart Degryse wrote: > Dear all, > I'm having a problem with transactions and exceptions and need your advice. > I want a function to do two things: > - log something to a table (which is basically an insert) > - raise an exception under certain conditions > My problem is that when I raise the exception the insert is rolled back. > How can I work around that? Either: 1. Not raising an exception, instead returning a status code to the application. 2. Using dblink / dbi-link to reconnect to the database, which means your logging will take place in its own transaction. -- Richard Huxton Archonet Ltd