Received: from mail.perdue.net (c696732-a.west1.ia.home.com [24.22.227.157]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f2EIEex56968 for ; Wed, 14 Mar 2001 13:14:40 -0500 (EST) (envelope-from tperdue@mail.perdue.net) Received: (from tperdue@localhost) by mail.perdue.net (8.11.2/8.11.2/Debian 8.11.2-1) id f2EIDa212379; Wed, 14 Mar 2001 12:13:36 -0600 Date: Wed, 14 Mar 2001 12:13:35 -0600 From: Tim Perdue To: Tom Lane Cc: pgsql-sql@postgresql.org Subject: Re: Rule/currval() issue Message-ID: <20010314121335.S670@mail.perdue.net> References: <20010314115015.R670@mail.perdue.net> <28311.984593358@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.12i In-Reply-To: <28311.984593358@sss.pgh.pa.us>; from tgl@sss.pgh.pa.us on Wed, Mar 14, 2001 at 01:09:18PM -0500 X-Archive-Number: 200103/285 X-Sequence-Number: 1949 On Wed, Mar 14, 2001 at 01:09:18PM -0500, Tom Lane wrote: > Tim Perdue writes: > > This is related to the plpgsql project I was working on this morning. I'm > > trying to create a rule, so that when a row is inserted into a certain table, > > we also create a row over in a "counter table". The problem lies in getting > > the primary key value (from the sequence) so it can be inserted in that > > related table. > > You probably should be using a trigger, not a rule at all. OK - so another rule like this one, is probably ill-advised as well? It seems a lot easier than going into the triggers: CREATE RULE forum_delete_agg AS ON DELETE TO forum DO UPDATE forum_agg_msg_count SET count=count-1 WHERE group_forum_id=old.group_forum_id; Tim -- Founder - PHPBuilder.com / Geocrawler.com Lead Developer - SourceForge VA Linux Systems