Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1huPMe-0008H9-NK for pgsql-general@arkaria.postgresql.org; Sun, 04 Aug 2019 22:52:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1huPMd-0004Jc-7A for pgsql-general@arkaria.postgresql.org; Sun, 04 Aug 2019 22:52:31 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1huPMc-0004JV-Rn for pgsql-general@lists.postgresql.org; Sun, 04 Aug 2019 22:52:30 +0000 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1huPMZ-0006Tf-LK for pgsql-general@postgresql.org; Sun, 04 Aug 2019 22:52:30 +0000 Received: by mail-ot1-x343.google.com with SMTP id l15so83433720otn.9 for ; Sun, 04 Aug 2019 15:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lucee.org; s=google; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=FB2XklYvlc4+PMmUStEV041juvQcJXw6XgT+vBEt280=; b=hD/Xe+xkfY88PyBByCE5OnzFyHWdDJJ8+j4n5DDNO5iGqJWv8ZEsjvkrwpe2k7mQCq PVHxgZkaplntKdqcDjbIb8eBDn1hsqjEFnJjkmem0pfDT0jJkOxQZED2yDxs+ehKTvMx 6NJHmgQvzp94/5mCDVHFlthcxRyjW8Umw9T5DnxuhnMvfImdkgW2IMrTGLO555y8CbHQ Honexvol95Lze5wgMkemVzoN/eDxEuimmluQY7Yt3Zqf+Na1FGVXlPmyt26VUP3EWc/4 AFjcQ+Q6KiqPwPdohi9l2MliElyLUi25aqt2of4b5DC5oeGTbPcI6sCPwoHyXkSxw8jq SjSQ== 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=FB2XklYvlc4+PMmUStEV041juvQcJXw6XgT+vBEt280=; b=Zlf4O/5oZKJyJrzq+HMIEMSlIaWzorkjQCUhCbONxDSB01piAdw9ZJSTIR8rYF2NsF cS2JIXMLl3SxpyQc6fYw6yUkC5NUk11RwZNTfS2+DqYZ02omPE9Y5g4j9vuEFmMqjmKz nHp550ddvEL7ZDhc+ZhHcLBkTy8pFMmPDeRrfClA1bIXO87W7mX2bV5wgHb77yppF33h reGuiz+PI6ey5X5SxuY3LVjTPQukcENEKG2UAh7edcZmVfwUTI1qZmM4Bcdr7drn45G3 5dq9oV6JMwuyyP4xWZtMTZ7SpASqbozbQYuPCGf3664x8YGxXD5ws6fjEC9WhxGvUE/w x7oA== X-Gm-Message-State: APjAAAXOOrvBAbrt3vEPMG7vLOwket6YeCTcqRDT3qeY1FXme3L+nK2n B1uRuqzViNZcLNb0r99DPVbCoigtC7Y= X-Google-Smtp-Source: APXvYqw4rMR1JmfeIMSTjFxvqTAzhm0WbEBZthpOx/FkAy0OLRBuhmGbMExCJiVWYLKjp/ahUhfbXg== X-Received: by 2002:a05:6830:11d4:: with SMTP id v20mr105674293otq.121.1564959143991; Sun, 04 Aug 2019 15:52:23 -0700 (PDT) Received: from ?IPv6:2600:1700:4000:8120:2d11:8431:dd44:a8eb? ([2600:1700:4000:8120:2d11:8431:dd44:a8eb]) by smtp.googlemail.com with ESMTPSA id k24sm24956926oic.29.2019.08.04.15.52.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2019 15:52:23 -0700 (PDT) To: pgsql-general From: "Igal @ Lucee.org" Subject: How to check if a field exists in NEW in trigger Message-ID: <0cc87310-590f-740e-977d-bcdde57eef1b@lucee.org> Date: Sun, 4 Aug 2019 15:52:22 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------B64BE4BBDE6D80C88074012E" 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. --------------B64BE4BBDE6D80C88074012E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit I have the following statement in a trigger:     new.email = lower(new.email); When I try to update a record without setting the email column however, I get an error: SQL Error [42703]: ERROR: record "new" has no field "email"   Where: SQL statement "SELECT lower(new.email)" PL/pgSQL function on_record_modified() line 26 at assignment I have seen some hacks suggesting TRY/CATCH or converting to a JSON and checking if the field exists, but I would think that there's a better way to check if the field is in the NEW record, no? Any ideas?  Thanks! Igal Sapir Lucee Core Developer Lucee.org --------------B64BE4BBDE6D80C88074012E Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

I have the following statement in a trigger:

    new.email = lower(new.email);

When I try to update a record without setting the email column however, I get an error:

SQL Error [42703]: ERROR: record "new" has no field "email"
  Where: SQL statement "SELECT lower(new.email)"
PL/pgSQL function on_record_modified() line 26 at assignment

I have seen some hacks suggesting TRY/CATCH or converting to a JSON and checking if the field exists, but I would think that there's a better way to check if the field is in the NEW record, no?

Any ideas?  Thanks!

Igal Sapir
Lucee Core Developer
Lucee.org

--------------B64BE4BBDE6D80C88074012E--