Re: Rules aren't doing what I expect

From: Ang Chin Han <angch(at)pintoo(dot)com>
To: Mark Volpe <volpe(dot)mark(at)epamail(dot)epa(dot)gov>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Rules aren't doing what I expect
Date: 2000-08-10 02:18:20
Message-ID: 20000810101820.A8537@pintoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Mark Volpe 2000-08-10 14:22:47 Re: Rules aren't doing what I expect
Previous Message Mark Volpe 2000-08-09 16:04:13 Rules aren't doing what I expect