Re: update trigger not working - Mailing list pgsql-general

From Mike Nolan
Subject Re: update trigger not working
Date
Msg-id 200510200250.j9K2oijO029318@gw.tssi.com
Whole thread Raw
In response to update trigger not working  (CSN <cool_screen_name90001@yahoo.com>)
List pgsql-general
> I'm trying to set up a trigger that simply updates a
> field's corresponding timestamp to now() whenever the
> field is updated. But it's not working. Trying to
> debug, I commented out the inner IF and END and the
> log seemed to indicate infinite recursion occurred. My
> next guess is that perhaps NULL's in OLD.stuff is
> causing the IF to behave other than what I expect.

Let me see if I have this right.

You have an 'after-update' trigger on a table that does an update on that
same table, and you're wondering why that creates an infinite loop?

You need to do this in a 'before-update' trigger and set NEW.timestamp,
then return NEW.
--
Mike Nolan



pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: [HACKERS] Call for translators
Next
From: Oliver Elphick
Date:
Subject: Re: update trigger not working