Skip site navigation (1) Skip section navigation (2)

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: (view raw or whole 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(;

> 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


pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group