Re: new and old not available in rule subselects?

Поиск
Список
Период
Сортировка
Искать
От
redhog
Тема
Re: new and old not available in rule subselects?
Дата
Msg-id
1162554691.465201.174850@h54g2000cwb.googlegroups.com
Ответ на
Список
Дерево обсуждения
new and old not available in rule subselects? Egil Möller <redhog@redhog.org>
Re: new and old not available in rule subselects? Shane Ambler <pgsql@007Marketing.com>
Re: new and old not available in rule subselects? "redhog" <redhog@redhog.org>
Re: new and old not available in rule subselects? Shane Ambler <pgsql@007Marketing.com>
> select count(*) from new ??? - new refers to a record not a table name

In the description in the manual, new and old are described as
relations... Also, isn't the point that the query is rewritten into the
new query with rules, thus if you update more than one row, new should
be all the updated rows, not just one at a time (a rule is not a
trigger)?

>
> Try
>
> create rule user_insert_count as
>   on update to "user"
>   do also
>    insert into users (time,users) values (
>     new.created, (select count(*) from "user" where destroyed is null));

I tried that, but "user" only contains the old (non-updated) records,
so the record count will be off by one in either direction...

Regards,
Egil

В списке pgsql-general по дате отправления
От: Magnus Hagander
Дата:
От: Jorge Godoy
Дата:
FAQ