Sarah Asmaels wrote:
Hi!

I have one table referencing an object in another table through an ID,
and a view joining those tables on the ID. I want to create rules to
rewrite updates/deletes/inserts on the joined view to act on the real
tables. Can you give me some pointers? The documentation has only
examples for views depending on single tables.

Thank you,

Sarah

Is there any difference in multi or single table view? When you create a rule, you have access to NEW and/or OLD, which will contain all the fields your view has. You can then do something like this:

CREATE RULE insert_rule AS ON INSERT TO your_view DO INSTEAD (
        INSERT INTO table1 (name) VALUES (NEW.name);
        INSERT INTO table2 (favorite_color) VALUES (NEW.favorite_color);
);

Or is there something I'm not understanding about your request, or perhaps rules in general?

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to