Triggers for inserting on VIEWS - Mailing list pgsql-sql

From Marc SCHAEFER
Subject Triggers for inserting on VIEWS
Date
Msg-id Pine.LNX.3.96.1020803193426.6029A-100000@defian.alphanet.ch
Whole thread Raw
Responses Re: Triggers for inserting on VIEWS  ("Josh Berkus" <josh@agliodbs.com>)
Re: Triggers for inserting on VIEWS  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Triggers for inserting on VIEWS  (Marc SCHAEFER <schaefer@alphanet.ch>)
List pgsql-sql
Hi,

at least with PostgreSQL 7.1 it was possible to create a trigger on a
view. 7.2 seems to fail with:
  psql:t:25: ERROR:  CreateTrigger: relation "egg_view" is not a table

is there any replacement so that inserting somewhere acts on multiple
tables ?

Thank you.

Code reference: (stupid, real code is more complex and uses multiple                tables)

DROP TRIGGER t_egg ON egg_view;
DROP FUNCTION f_egg_insert ();
DROP VIEW egg_view;
DROP TABLE egg;
DROP SEQUENCE egg_id_seq;

CREATE TABLE egg(id SERIAL,                description TEXT,                UNIQUE(id), PRIMARY KEY(id));

CREATE VIEW egg_view  AS SELECT description FROM egg;

CREATE FUNCTION f_egg_insert ()  RETURNS opaque  AS 'BEGIN         INSERT INTO egg (description)
VALUES(NEW.description);     END;'  LANGUAGE 'plpgsql';
 

CREATE TRIGGER t_egg  BEFORE INSERT  ON egg_view  FOR EACH ROW  EXECUTE PROCEDURE f_egg_insert();






pgsql-sql by date:

Previous
From: "Josh Berkus"
Date:
Subject: Re: [NOVICE] Aggregates and Indexes
Next
From: "Josh Berkus"
Date:
Subject: Re: Triggers for inserting on VIEWS