Re: before insert for each row trigger on upsert

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Ted Toth <txtoth(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: before insert for each row trigger on upsert
Date: 2020-02-20 20:32:09
Message-ID: 18def70d-c2c4-ff92-b488-243ed0287001@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/20/20 12:17 PM, Ted Toth wrote:
> I'm a little confused why the before insert trigger fires al all but
> since it does is  there a way to know that an update will occur?

Because ON CONFLICT DO UPDATE is part of an INSERT command.

> Basically I don't want the trigger affect the row on update.

Not sure that a BEFORE trigger will work for that anyway as it will not
have submitted the data yet for ON CONFLICT resolution.

>
> Ted

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrus 2020-02-20 20:35:20 How to fix 0xC0000005 exception in Postgres 9.0
Previous Message Ted Toth 2020-02-20 20:17:25 before insert for each row trigger on upsert