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 8BADF9DC986 for ; Mon, 19 Dec 2005 05:08:45 -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 91497-10 for ; Mon, 19 Dec 2005 05:08:46 -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 416A79DC980 for ; Mon, 19 Dec 2005 05:08:42 -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 AEAA1428F9F; Mon, 19 Dec 2005 09:08:06 +0000 (GMT) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 9D99715EA4; Mon, 19 Dec 2005 09:08:10 +0000 (GMT) Message-ID: <43A67879.3050003@archonet.com> Date: Mon, 19 Dec 2005 09:08:09 +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: <003801c60284$b404a620$6603a8c0@kenxp> In-Reply-To: <003801c60284$b404a620$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 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200512/154 X-Sequence-Number: 23696 Ken Winter wrote: > This rule is supposed to (1) cause an update directed to the view > "my_data_now" to be made to the underlying table "my_data", (2) reset the > "effective_date_and_time" of that row to 'now', (3) insert a record > containing the old values into "my_data", and (4) expire that "old" record > by setting its "expiration_date_and_time" to 'now'. I think you want a trigger rather than a rule. Rules rewrite the query structure, triggers let you deal with values on a row-by-row basis (for row-level triggers). -- Richard Huxton Archonet Ltd