Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdJ31-00021Z-3d for pgsql-general@arkaria.postgresql.org; Wed, 11 Jul 2018 17:37:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fdJ2z-0007hL-Hz for pgsql-general@arkaria.postgresql.org; Wed, 11 Jul 2018 17:37:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdJ2z-0007hE-6R for pgsql-general@lists.postgresql.org; Wed, 11 Jul 2018 17:37:01 +0000 Received: from mail-yw0-x242.google.com ([2607:f8b0:4002:c05::242]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fdJ2v-00035b-JS for pgsql-general@postgresql.org; Wed, 11 Jul 2018 17:37:00 +0000 Received: by mail-yw0-x242.google.com with SMTP id q129-v6so6654177ywg.8 for ; Wed, 11 Jul 2018 10:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lucee-org.20150623.gappssmtp.com; s=20150623; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=Li9GHQjeBdotI6dmZLlp+AH0k6CWaTffrXNKYEfjsII=; b=GhQtL4Bpq8fuRR9Ke2pvOQvyEIkN2hg6UBypF7O05XvQzltMqtQpdxMAVXiYqidPHx c/Ha53SvwNTbAauJcVmx8TzaXSQtN7bUrGPW/t2JgKhTyssCl0HxfSSymaJw2eN6k4dc lZpaZn0YZJA9YbQ+oH5/oUoX8n4CsSBy7e3jngqSQnjDc6iW4on7qZGqcgdrf9Me+LZz rxy4xa3XlyCVe6s6Xv6kW5FKr7CxYX0zqIL53Q8NioIDv4JzTZn88mP2tMl9W+d4Jreh 59EwRkUsKHEphWMMHRodXU62+suM5KDB6bdlCMCIW1CYVZ9zjloHdzqG2Nnr1T/9U09W yK6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=Li9GHQjeBdotI6dmZLlp+AH0k6CWaTffrXNKYEfjsII=; b=VRCYqGT7jEZ+8PDYj6l2EqLcXIYJf1EZokl4NGoNcy/HsW7OcNqTS2KrYnu5Pafuig NMkTbhM/HdqzutvtgKZW/+wWRS8snWeyJugtU98dXpmYvfxZwa1IOt5vBHL6BcuE3f1O UuuUvh0r5SQbjYGfVM2ykUwZ5idHQUnbpALOwo4dzMYtI2lSq70+8QHXS/0tGEL1PquX MQOCm7ymqMFQ35jS4LDg3fFkhy5lhLUpYCYc1rYH1c5HVmuUmzE5ZjF+Rv3t8a0/fu1s QOEozvVVX+6IMkkzvBIZSEs9WW3JxupOn2PNzv6A1pxiruE7cYNI/k49nRkSNI2OCAVT Ik5w== X-Gm-Message-State: APt69E1UNEkE6CyIjEYbDyMJxxtOSQABg4FfwAPd/61gqimacuX27nT+ OwpUHDKmt5QBUv/9konEjUrEjyzv X-Google-Smtp-Source: AAOMgpfKWw5qOY0LBUB45k854dJSuMPnp1H8yUg2Sb3dgdm2FfwytaHjr/xMem+As/jLaXk+cW9kDg== X-Received: by 2002:a81:7d43:: with SMTP id y64-v6mr14283588ywc.371.1531330615248; Wed, 11 Jul 2018 10:36:55 -0700 (PDT) Received: from ?IPv6:2600:1700:4000:8120:796c:3217:5784:98f0? ([2600:1700:4000:8120:796c:3217:5784:98f0]) by smtp.googlemail.com with ESMTPSA id k184-v6sm8649150ywc.95.2018.07.11.10.36.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jul 2018 10:36:54 -0700 (PDT) To: pgsql-general From: "Igal @ Lucee.org" Subject: How to tell which event was fired in Trigger function Message-ID: Date: Wed, 11 Jul 2018 10:36:49 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------CFB9E0DE3644A9F0B680C5E0" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------CFB9E0DE3644A9F0B680C5E0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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 --------------CFB9E0DE3644A9F0B680C5E0 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

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

--------------CFB9E0DE3644A9F0B680C5E0--