Re: Conditional rule?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Conditional rule?
Дата
Msg-id 8320.964712170@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Conditional rule?  ("André Næss" <andre.nass@student.uib.no>)
Ответы Re: Conditional rule?  (JanWieck@t-online.de (Jan Wieck))
Список pgsql-sql
"André Næss" <andre.nass@student.uib.no> writes:
> I wish to make rule looking something like this:
> create rule newsrule as
>   on insert to news do
>     if new.publishtime is not null insert into news_unpublished
> values(new.id);

> I.e. "On an insert to news, if new.publish is not null, insert the new
> post's id into news_unpublished.

What you want here is a trigger, not a rule.  The closest you could come
with a rule is to copy *all* unpublished ids into news_unpublished each
time something got inserted into news.  There are applications for that
sort of thing, but this ain't it.  See the trigger examples in the
plpgsql or pltcl sections of the manual.
        regards, tom lane


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

Предыдущее
От: Itai Zukerman
Дата:
Сообщение: Automatic Deletes?
Следующее
От: "André Næss"
Дата:
Сообщение: Re: Conditional rule?