updating a view

Поиск
Список
Период
Сортировка
От m.c.wilkins@massey.ac.nz
Тема updating a view
Дата
Msg-id 20061215004245.GO20895@massey.ac.nz
обсуждение исходный текст
Ответы Re: updating a view  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
hi,

i would like to allow updates to a view, but pgsql crashes,
presummably from an infinite loop.

i add a rule like so:

   CREATE RULE update_myview AS ON UPDATE TO myview DO INSTEAD SELECT updater(OLD, NEW);

where updater is a plperl function.  the function updater does a few
comparisons off OLD and NEW (to see what has changed) and then, if
necessary, updates one of the tables that makes up myview:

   spi_exec_query("UPDATE mytable SET somefield = somevalue WHERE somecondition");

i can supply the exact code if you wish, but i think the problem lies
more with my approach than the syntax.  what i think is happening is
that the "update mytable set blah blah" statement is executed, but
that causes an update to myview, which causes my rule to run, which
runs updater etc etc.

i'm not sure how to get around this problem though.  how can i do a
UPDATE myview SET foo = bar, and get that to work without using a
rule, that ends up updating a table that updates myview?

thank you for any help!

matt



В списке pgsql-general по дате отправления:

Предыдущее
От: Ben
Дата:
Сообщение: Re: a question for the way-back machine
Следующее
От: Tom Lane
Дата:
Сообщение: Re: updating a view