X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CFE21D7AC5 for ; Sun, 20 Nov 2005 11:40:31 -0400 (AST) 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 90596-09 for ; Sun, 20 Nov 2005 15:40:35 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp-out2.blueyonder.co.uk (smtp-out2.blueyonder.co.uk [195.188.213.5]) by svr1.postgresql.org (Postfix) with ESMTP id EFECFD7C47 for ; Sun, 20 Nov 2005 11:40:28 -0400 (AST) Received: from Eve ([82.43.185.102]) by smtp-out2.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.6713); Sun, 20 Nov 2005 15:41:27 +0000 Reply-To: From: Andy Ballingall To: "'Jaime Casanova'" Cc: Subject: Re: Is it possible to redirect an update/insert/delete to a different table? Date: Sun, 20 Nov 2005 15:40:41 -0000 Organization: Areyoulocal 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 Thread-Index: AcXt3hyzIjxuelHqQmeWq0aR+gRpBwACZpcg In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Message-ID: X-OriginalArrivalTime: 20 Nov 2005 15:41:27.0132 (UTC) FILETIME=[DE8411C0:01C5EDE8] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[AWL=0.000] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/170 X-Sequence-Number: 23421 Hello Jaime, I'm still not quite clear. Say I have a number of different updates on a table 'apples' in my code, including: UPDATE apples set pips=6 and color='yellow' where id=3; UPDATE apples set size=10 where id=6; What would a rule look like which, when *any* update is attempted on the apples table, will instead apply the update to a different table - 'pears'. I get this far: CREATE rule pears_instead_of_apples AS ON UPDATE TO apples DO INSTEAD UPDATE INTO pears .....; What do I put where the ..... is, so that the rule will transparently update the pears table with whatever values happened to be defined by the original update command? Is there a special keyword that I've missed? Regards, Andy Ballingall -----Original Message----- From: Jaime Casanova [mailto:systemguards@gmail.com] Sent: 20 November 2005 14:23 To: andy@areyoulocal.co.uk Cc: pgsql-sql@postgresql.org Subject: Re: Is it possible to redirect an update/insert/delete to a different table? > I've looked through rules, and as far as I can make out, they are only > useful for explicit actions. I'm looking for something that behaves as > though it simply substitutes the table name for a different table name > before executing the command, no matter what the command looks like. > Make 3 rules (INSERT/UPDATE/DELETE), 4 if you want SELECT as well... -- regards, Jaime Casanova (DBA: DataBase Aniquilator ;) -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.362 / Virus Database: 267.13.4/176 - Release Date: 20/11/2005