Re: Conditional rule?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: André Næss <andre(dot)nass(at)student(dot)uib(dot)no>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Conditional rule?
Date: 2000-07-27 15:36:10
Message-ID: 8320.964712170@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"=?iso-8859-1?B?QW5kcukgTuZzcw==?=" <andre(dot)nass(at)student(dot)uib(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message André Næss 2000-07-27 17:21:55 Re: Conditional rule?
Previous Message Itai Zukerman 2000-07-27 15:12:54 Automatic Deletes?