Re: update trigger not working

From: Mike Nolan <nolan(at)gw(dot)tssi(dot)com>
To: cool_screen_name90001(at)yahoo(dot)com (CSN)
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: update trigger not working
Date: 2005-10-20 02:50:43
Message-ID: 200510200250.j9K2oijO029318@gw.tssi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Oliver Elphick 2005-10-20 02:52:33 Re: update trigger not working
Previous Message Alvaro Herrera 2005-10-20 02:49:42 Re: [HACKERS] Call for translators