Re: Trigger question
От | Tom Lane |
---|---|
Тема | Re: Trigger question |
Дата | |
Msg-id | 11294.975345620@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Trigger question (Nelio Alves Pereira Filho <nelio@ifx.com.br>) |
Список | pgsql-general |
Nelio Alves Pereira Filho <nelio@ifx.com.br> writes: > To accomplish all that, first I need > to unset some values, so I decided to use the BEFORE trigger to unset > these values, and the AFTER trigger to do this calculation. Why don't you just do all the work in the BEFORE trigger? > And what's the real purpose of the AFTER trigger? The sequence of events is compute contents of tuple to insert/update (per the query) apply BEFORE triggers check constraints insert tuple apply AFTER triggers You *must* use a BEFORE trigger if you want to alter the tuple that was computed by the query. The point of an AFTER trigger is that it won't be run until constraints have been passed, so you can avoid doing potentially expensive work until you know the tuple is good. You might use an AFTER trigger to propagate changes into other tables, for example. But you can't change the tuple. regards, tom lane
В списке pgsql-general по дате отправления: