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();