Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.10.1/8.10.1) with ESMTP id e6RFaYA42144 for ; Thu, 27 Jul 2000 11:36:34 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id LAA08323; Thu, 27 Jul 2000 11:36:10 -0400 (EDT) To: "=?iso-8859-1?B?QW5kcukgTuZzcw==?=" cc: pgsql-sql@postgresql.org Subject: Re: Conditional rule? In-reply-to: <003601bff7d9$18cdd610$74b5f8c2@wkst6> References: <87k8e78yg9.fsf@matt.w80.math-hat.com> <003601bff7d9$18cdd610$74b5f8c2@wkst6> Comments: In-reply-to "=?iso-8859-1?B?QW5kcukgTuZzcw==?=" message dated "Thu, 27 Jul 2000 16:43:57 +0200" Date: Thu, 27 Jul 2000 11:36:10 -0400 Message-ID: <8320.964712170@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200007/260 "=?iso-8859-1?B?QW5kcukgTuZzcw==?=" 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