How to check if a field exists in NEW in trigger

Поиск
Список
Период
Сортировка
От Igal @ Lucee.org
Тема How to check if a field exists in NEW in trigger
Дата
Msg-id 0cc87310-590f-740e-977d-bcdde57eef1b@lucee.org
обсуждение исходный текст
Ответы Re: How to check if a field exists in NEW in trigger  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: How to check if a field exists in NEW in trigger  (Thomas Kellerer <spam_eater@gmx.net>)
Re: How to check if a field exists in NEW in trigger  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general

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

В списке pgsql-general по дате отправления:

Предыдущее
От: Julie Nishimura
Дата:
Сообщение: Re: adding more space to the existing server
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: How to check if a field exists in NEW in trigger