Re: CREATE RULE ON UPDATE/DELETE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joel Burton <joel(at)joelburton(dot)com>
Cc: Aasmund Midttun Godal <postgresql(at)envisity(dot)com>, pgsql-sql(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: CREATE RULE ON UPDATE/DELETE
Date: 2001-10-21 16:47:41
Message-ID: 28356.1003682861@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

Joel Burton <joel(at)joelburton(dot)com> writes:
> CREATE VIEW dbl AS SELECT id * 2 as id, name FROM raw;

> CREATE RULE dbl_update AS ON UPDATE TO dbl DO INSTEAD UPDATE raw SET
> id = NEW.id, name = NEW.name WHERE OLD.id = id;

Surely you'd need something like

CREATE RULE dbl_update AS ON UPDATE TO dbl DO INSTEAD UPDATE raw SET
id = NEW.id / 2, name = NEW.name WHERE OLD.id = id * 2;

(untested...)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Johann Zuschlag 2001-10-21 17:54:03 Re: Error while restoring database
Previous Message Tom Lane 2001-10-21 16:42:57 Re: Error while restoring database

Browse pgsql-sql by date

  From Date Subject
Next Message Stefan Lindner 2001-10-21 19:51:47 Re: system maintained keys
Previous Message Stephan Szabo 2001-10-21 08:33:59 Re: CREATE RULE ON UPDATE/DELETE