Re: How to tell which event was fired in Trigger function

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: "Igal (at) Lucee(dot)org" <igal(at)lucee(dot)org>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to tell which event was fired in Trigger function
Date: 2018-07-11 17:38:14
Message-ID: 4fb09bff-b6db-e889-b4f0-9839bce44100@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07/11/2018 10:36 AM, Igal @ Lucee.org wrote:
> Hi,
>
> I am writing a trigger function that is used after DELETE, INSERT, and
> UPDATE, like so:
>
>     CREATE TRIGGER tr_name AFTER DELETE OR INSERT OR UPDATE ...
>
> How can I tell inside the trigger function if the event was DELETE or
> INSERT/UPDATE?
>
> The table has a `NOT NULL id` column, so I am thinking that maybe a
> DELETE will have a NULL value in NEW.id?  Will that work?  Is there a
> better way?

https://www.postgresql.org/docs/10/static/plpgsql-trigger.html

>
> Thanks,
>
> Igal Sapir
> Lucee Core Developer
> Lucee.org <http://lucee.org/>
>

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Igal @ Lucee.org 2018-07-11 17:54:56 Re: How to tell which event was fired in Trigger function
Previous Message Igal @ Lucee.org 2018-07-11 17:36:49 How to tell which event was fired in Trigger function