Re: Updates thru view

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Updates thru view
Дата
Msg-id 13795.1014066920@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Updates thru view  ("Rajshekar" <riyer@kc.rr.com>)
Список pgsql-general
"Rajshekar" <riyer@kc.rr.com> writes:
> create rule rule_update AS on update to shek_view
>         where old.age = 24
>         do  update shek_tab set age = new.age where old.age = 24 ;

Try

create rule rule_update AS on update to shek_view
        where old.age = 24
        do  update shek_tab set age = new.age where age = old.age;

Your form of the rule reduces to
    update shek_tab set age = new.age where true;
which unsurprisingly updates all rows of the table.

I do not exactly see the point of the conditional rule, either.
Why not just

create rule rule_update AS on update to shek_view
        do  update shek_tab set age = new.age where age = old.age;

The view already restricts visibility of rows, you do not need to
do it twice more in the rules.

            regards, tom lane

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

Предыдущее
От: wsheldah@lexmark.com
Дата:
Сообщение: Re: Sum of events over an interval; how?
Следующее
От: "Gregory Wood"
Дата:
Сообщение: Re: at time zone question in pl/pgSQL