How to tell which event was fired in Trigger function

From: "Igal (at) Lucee(dot)org" <igal(at)lucee(dot)org>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: How to tell which event was fired in Trigger function
Date: 2018-07-11 17:36:49
Message-ID: a389c8ed-ad53-8622-2b16-2f0c84141d25@lucee.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

Thanks,

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2018-07-11 17:38:14 Re: How to tell which event was fired in Trigger function
Previous Message Adam Brusselback 2018-07-11 16:59:42 Re: Using CTE vs temporary tables