Re: Conditional rule? - Mailing list pgsql-sql

From Tom Lane
Subject Re: Conditional rule?
Date
Msg-id 8320.964712170@sss.pgh.pa.us
Whole thread Raw
In response to Conditional rule?  ("André Næss" <andre.nass@student.uib.no>)
Responses Re: Conditional rule?  (JanWieck@t-online.de (Jan Wieck))
List 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 by date:

Previous
From: Itai Zukerman
Date:
Subject: Automatic Deletes?
Next
From: "André Næss"
Date:
Subject: Re: Conditional rule?