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 F38619DC9B8 for ; Mon, 19 Dec 2005 12:08:32 -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 73465-02 for ; Mon, 19 Dec 2005 12:08:30 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id C08CE9DC9B6 for ; Mon, 19 Dec 2005 12:08:29 -0400 (AST) Received: from mainbox.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 6AD764292D3; Mon, 19 Dec 2005 16:05:02 +0000 (GMT) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 8C3A315EA6; Mon, 19 Dec 2005 16:05:13 +0000 (GMT) Message-ID: <43A6DA39.2080509@archonet.com> Date: Mon, 19 Dec 2005 16:05:13 +0000 From: Richard Huxton User-Agent: Thunderbird 1.5 (X11/20051025) MIME-Version: 1.0 To: Ken Winter Cc: 'PostgreSQL pg-sql list' Subject: Re: Rule causes baffling error References: <009c01c604b3$1b007630$6603a8c0@kenxp> In-Reply-To: <009c01c604b3$1b007630$6603a8c0@kenxp> 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, score=0.004 required=5 tests=[AWL=0.004] X-Spam-Score: 0.004 X-Spam-Level: X-Archive-Number: 200512/165 X-Sequence-Number: 23707 Ken Winter wrote: > Richard ~ > > Thanks for your response. > > Can a trigger be written on a *view*? I can't find anything in the > PostgreSQL docs that answers this question. There's nothing for them to fire against even if you could attach the trigger. I suppose you could have a statement-level trigger in more recent versions, but for row-level triggers there aren't any rows in the view to be affected. > I originally wrote these actions (described in my original message) as a > trigger on my base table, but then realized I was getting in deeper and > deeper trouble because (a) I was getting into cascading triggers that I > didn't want and (b) I need to enable some queries to access the base table > without triggering these actions. That's why I set up the view, and then I > assumed that the only way I could implement these actions was as rules. Hmm - the cascading should be straightforward enough to deal with. When you are updating check if NEW.expiration_date_and_time = now() and if so exit the trigger function (since there's nothing to do anyway). The other thing you might want to consider is whether the "live" data should be in the same table as the "old" data. That will depend on how you want to use it - conceptually is it all one continuum or is the "old" data just for archive purposes. Now, having got this feature working, why do you want to bypass it? Will it be a specific user, involve specific patterns of values or what? -- Richard Huxton Archonet Ltd