Re: writable joined view
От | Wiebe Cazemier |
---|---|
Тема | Re: writable joined view |
Дата | |
Msg-id | 435E200C.5090405@gmail.com обсуждение исходный текст |
Ответ на | writable joined view (Sarah Asmaels <sarah@spiesonline.net>) |
Список | pgsql-sql |
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?
В списке pgsql-sql по дате отправления: