Joined table view - multiple delete action rule

From: Lieven Van Acker <lieven(at)elisa(dot)be>
To: pgsql-general(at)postgresql(dot)org
Subject: Joined table view - multiple delete action rule
Date: 2001-04-25 14:17:33
Message-ID: 3AE6DC7D.B8FEB0E4@elisa.be
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

I'm coding a DB and I noticed the following strange thing:

CREATE TABLE a (x integer PRIMARY KEY,y integer);
CREATE TABLE b (x integer REFERENCES a, z integer, PRIMARY KEY (x,y))

CREATE VIEW ab AS
SELECT a.x, a.y, b.z
FROM a,b
WHERE a.x=b.x;

/* this -insert- seems to work */

CREATE RULE ab_ins AS ON INSERT TO ab DO INSTEAD (
INSERT INTO a(x,y) VALUES (new.x, new.y);
INSERT INTO b(x,z) VALUES (new.x, new.z);
);

/* this -delete- does not work */

CREATE RULE ab_del AS ON DELETE TO ab DO INSTEAD (
DELETE FROM b WHERE (x=old.x) AND (y=old.y);
DELETE FROM a WHERE (x=old.x);
);

Anyone has an explanation for this? I'm using PostgreSQL 7.0.3.

Greetings,

Lieven

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jan Ploski 2001-04-25 14:26:14 SUM()ming a view's column
Previous Message Geoff Caplan 2001-04-25 14:12:26 Newbie struggling to set $PGDATA