Re: Detection of which attributes should get set in update trigger

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Detection of which attributes should get set in update trigger
Дата
Msg-id CAKFQuwaKwWecLH7fchrm-0hn-LKR6c3ki4C9x8dR0BRM+itueg@mail.gmail.com
обсуждение исходный текст
Ответ на Detection of which attributes should get set in update trigger  (Thiemo Kellner <thiemo@gelassene-pferde.biz>)
Ответы Re: Detection of which attributes should get set in update trigger
Список pgsql-general
On Friday, November 10, 2023, Thiemo Kellner <thiemo@gelassene-pferde.biz> wrote:
Hi all

I have a view, that is a join over 4 tables (the setup of the rule question). I want to update the central table over the view (by an instead-of trigger). How can I determine, whether an attribute should get set to NULL, "new.XYZ is null" or whether it should be left alone. Is there a leave-me-alone function determining, whether an attribute is in the set clause of an update statement. I am thinking along the line code in the trigger function like

update TABLE
   set XYZ = case
                  when leave-me-alone (new.XYZ) then old.XYZ
                  else new.XYZ
             end;

And what about the where condition... hm, guess I am a bit confused.

IIUC, The NEW record is complete, with every value as it should be in the newly saved tuple.  There is no leave-me-alone concept.  You don’t get to know if the column was specified or not in the update command.

David J.

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

Предыдущее
От: Thiemo Kellner
Дата:
Сообщение: Detection of which attributes should get set in update trigger
Следующее
От: Thiemo Kellner
Дата:
Сообщение: Re: Detection of which attributes should get set in update trigger