| From: | Marc SCHAEFER <schaefer(at)alphanet(dot)ch> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Triggers for inserting on VIEWS |
| Date: | 2002-08-03 18:04:25 |
| Message-ID: | Pine.LNX.3.96.1020803193426.6029A-100000@defian.alphanet.ch |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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();
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joshua D. Drake | 2002-08-03 18:32:20 | Re: RES: The best book |
| Previous Message | Josh Berkus | 2002-08-03 16:40:50 | Re: [SQL] Aggregates and Indexes |