X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id EFB999DC88D for ; Thu, 2 Mar 2006 20:19:28 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11905-09 for ; Thu, 2 Mar 2006 20:19:31 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp03l.fasthosts.co.uk (smtp.fasthosts.co.uk [213.171.216.50]) by postgresql.org (Postfix) with ESMTP id D39A79DC816 for ; Thu, 2 Mar 2006 20:19:26 -0400 (AST) Received: from aurora (213-78-152-15.ppp.onetel.net.uk [213.78.152.15]) by smtp03l.fasthosts.co.uk (Postfix) with ESMTP id 9C6B719B6A3 for ; Fri, 3 Mar 2006 00:19:28 +0000 (GMT) From: "Simon Kinsella" To: Subject: Re: Help with trigger that updates a row prior to a potentially aborted deletion? Date: Fri, 3 Mar 2006 00:19:22 -0000 Organization: Bluefire Systems Ltd MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 Thread-Index: AcY986dPgJX1RmufQFSih6g0DVsljgAYTuDQ In-Reply-To: <20060302121943.GA7057@phlogiston.dyndns.org> Message-Id: <20060303001928.9C6B719B6A3@smtp03l.fasthosts.co.uk> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200603/54 X-Sequence-Number: 24400 Hi Andrew, I think I may have cracked this problem by combining a RULE ON DELETE which calls a function instead of the standard DELETE op. No triggers. It was a real nightmare as it was my first attempt at a rule and it kept ending up in circular self-references. In the end though it boiled down to a pretty compact solution. It's getting late now but I'll be testing it out properly tomorrow. I can post it up then if you're interested. Thanks for your help, Simon -----Original Message----- From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Andrew Sullivan Sent: Thursday, March 02, 2006 12:20 PM To: pgsql-sql@postgresql.org Subject: Re: [SQL] Help with trigger that updates a row prior to a potentially aborted deletion? On Wed, Mar 01, 2006 at 08:41:20PM -0000, Simon Kinsella wrote: > Ok thanks, will check this out. Is that the same as savepoints, or > something different? (am using 8.1.2) Yes, same thing. > At the moment I'm investigating using a rule (rewrite the DELETE as an > UPDATE to set the flag, then use an AFTER UPDATE trigger to attempt to > delete the row if the flag was set). Not sure if it's going to work > but if so I'll post back. In a message you sent that I read after I sent mine, you also said you had to be able to handle deletes from the table with CASCADE. My suggestion won't work for that, I don't think (but it might be worth a try). The only other thing I can think of is just flag everything, and use a daemon to go around and perform the actual deletes for you. A -- Andrew Sullivan | ajs@crankycanuck.ca The plural of anecdote is not data. --Roger Brinner ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq