If I understand correctly or if I not I would appreciate if you can advice me in the problem of using rules instead of "instead of insert/update/delete" on views.
If I have, for example three tables:
A (id, name)
B(fk1, name)
C(fk2, name)
And a view named V
create view V as
select * from A,B,C where A.id = B.fk1 and B.fk1 = C.fk2)
I would like to insert, update and delete in these three tables using the view. I cannot use instead of triggers because they are replaced with rules. But I don't know what is my mistake because I am informed that "ERROR: NEW used in query that is not in a rule" when I create the rule like that:
CREATE or replace RULE r AS ON INSERT TO v DO INSTEAD
INSERT INTO A (id, name) VALUES (NEW.id, NEW.name);
INSERT INTO B (fk1, name) VALUES (NEW.fk1, NEW.name);
INSERT INTO C (id, name) VALUES (NEW.fk2, NEW.name);
Can anyone tell me, please, in this example, how can I substitute an instead of view with a rule?
Thanks in advanced.