Received: from kosh.pollcities.com (kosh.pollcities.com [202.186.13.219]) by hub.org (8.10.1/8.10.1) with ESMTP id e7A2TKG77915 for ; Wed, 9 Aug 2000 22:29:39 -0400 (EDT) Received: (from angch@localhost) by kosh.pollcities.com (8.9.3/8.9.3) id KAA08667; Thu, 10 Aug 2000 10:18:20 +0800 Date: Thu, 10 Aug 2000 10:18:20 +0800 From: Ang Chin Han To: Mark Volpe Cc: pgsql-sql@postgresql.org Subject: Re: Rules aren't doing what I expect Message-ID: <20000810101820.A8537@pintoo.com> References: <399180FD.2ACF8B2D@epamail.epa.gov> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <399180FD.2ACF8B2D@epamail.epa.gov>; from volpe.mark@epamail.epa.gov on Wed, Aug 09, 2000 at 12:04:13PM -0400 X-Archive-Number: 200008/71 On Wed, Aug 09, 2000 at 12:04:13PM -0400, Mark Volpe wrote: > I have a table with a trigger that can potentially modify a row before it gets > inserted or updated: [snip] > I have another table that tracks changes in the first table with rules: AFAIK, rules get rewritten first, before triggers are invoked, so your rules are getting the values before your trigger changes them. > The t1_log table doesn't show what was actually inserted into t1! > Are there any changes I can make to the logic above so that t1_log can > show the correct value? Either somehow rewrite your trigger as a rule, or stick another trigger to change the value before getting into your log table. You might be able to reuse your trigger function, I think, just point the trigger to that function. A bit inefficient, since it gets called twice.