pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Igal @ Lucee.org <igal@lucee.org>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: How to tell which event was fired in Trigger function
Date: Wed, 11 Jul 2018 10:38:14 -0700
Message-ID: <4fb09bff-b6db-e889-b4f0-9839bce44100@aklaver.com> (raw)
In-Reply-To: <a389c8ed-ad53-8622-2b16-2f0c84141d25@lucee.org>
References: <a389c8ed-ad53-8622-2b16-2f0c84141d25@lucee.org>

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.klaver@aklaver.com




view thread (5+ messages)  latest in thread

Message-ID: <4fb09bff-b6db-e889-b4f0-9839bce44100@aklaver.com>
Permalink:  ../4fb09bff-b6db-e889-b4f0-9839bce44100@aklaver.com/
Also on:    postgresql.org/message-id/4fb09bff-b6db-e889-b4f0-9839bce44100@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, igal@lucee.org
  Subject: Re: How to tell which event was fired in Trigger function
  In-Reply-To: <4fb09bff-b6db-e889-b4f0-9839bce44100@aklaver.com>
  References: <a389c8ed-ad53-8622-2b16-2f0c84141d25@lucee.org> <4fb09bff-b6db-e889-b4f0-9839bce44100@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox