BEFORE UPDATE trigger also fires at insert?

From: Clemens Eisserer <linuxhippy(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: BEFORE UPDATE trigger also fires at insert?
Date: 2011-05-08 13:26:22
Message-ID: BANLkTikp_KHorR7AMYqUaAtcknX4svm3KA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I've defined a small trigger to increment a field each time the row is updated:

> CREATE TRIGGER inc_trigger BEFORE UPDATE ON Table FOR EACH ROW EXECUTE PROCEDURE inc_function();

Works quite well, however the trigger is also fired if the table
itself is modified.
When deleting or inserting a single row, the trigger is executed for
all rows contained in the table.

Is this intetional, and if so, how can I get the behaviour to only
execute the trigger when an update on the relation is performed?

Thank you in advance, Clemens

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-05-08 16:47:17 Re: BEFORE UPDATE trigger also fires at insert?
Previous Message Leonardo Francalanci 2011-05-08 06:57:21 FILLFACTOR and increasing index