Re: Using a TRIGGER with window functions.

Поиск
Список
Период
Сортировка
От Michael Lewis
Тема Re: Using a TRIGGER with window functions.
Дата
Msg-id CAHOFxGp8vGf8B9+hb37gakfHb-8TjTpfa6wCFr3vL6zrQEfQ+g@mail.gmail.com
обсуждение исходный текст
Ответ на Using a TRIGGER with window functions.  (Pól Ua Laoínecháin <linehanp@tcd.ie>)
Ответы Re: Using a TRIGGER with window functions.  (Pól Ua Laoínecháin <linehanp@tcd.ie>)
Список pgsql-general
If you want to update many rows after updating N rows, you want an after STATEMENT trigger which is executed after insert, update or delete. You also want to ensure that only that function maintains sort_order field and that you don't update recursively, perhaps by executing that function when NEW.sort_order IS NOT DISTINCT FROM old.sort_order to prevent an infinite loop, and executing a different function when NEW.sort_order IS DISTINCT FROM OLD.sort_order such that you ensure all other fields have not changed.

By the way, your window function could be row_number() - 1 instead of activity_id - FIRST_VALUE(activity_id).

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

Предыдущее
От: Andy Hall
Дата:
Сообщение: Re: postgres disconnects on master after setting up replication
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Using a TRIGGER with window functions.