Re: inherited table and rules

From: Klint Gore <kg(at)kgb(dot)une(dot)edu(dot)au>
To: Klint Gore <kg(at)kgb(dot)une(dot)edu(dot)au>
Cc: pgsql-general(at)postgresql(dot)org, Scott Frankel <leknarf(at)pacbell(dot)net>
Subject: Re: inherited table and rules
Date: 2005-03-23 07:34:01
Message-ID: 42411BE9132.97F8KG@129.180.47.120
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I think you can get what you want if you change the rule definition to

CREATE RULE
people_upd_history AS ON UPDATE TO people
DO INSERT INTO
people_history
SELECT * FROM only people WHERE usr_pkey = old.usr_pkey;

and your updates to be only's

-- update table (1) -- 2
UPDATE ONLY people SET color = 'cyan' WHERE usr_pkey = 1;

-- update table (2) -- 6
UPDATE ONLY people SET color = 'magenta' WHERE usr_pkey = 1;

-- update table (3) -- 42
UPDATE ONLY people SET color = 'yellow' WHERE usr_pkey = 1;

-- update table (4) -- 1806
UPDATE ONLY people SET color = 'black' WHERE usr_pkey = 1;

klint.

+---------------------------------------+-----------------+
: Klint Gore : "Non rhyming :
: EMail : kg(at)kgb(dot)une(dot)edu(dot)au : slang - the :
: Snail : A.B.R.I. : possibilities :
: Mail University of New England : are useless" :
: Armidale NSW 2351 Australia : L.J.J. :
: Fax : +61 2 6772 5376 : :
+---------------------------------------+-----------------+

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Shaun Clements 2005-03-23 09:15:49 PLPGSQL
Previous Message Klint Gore 2005-03-23 07:04:54 Re: inherited table and rules