Re: Trigger question: ROW or STATEMENT?

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Trigger question: ROW or STATEMENT?
Дата
Msg-id 20060126035209.GA93569@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: Trigger question: ROW or STATEMENT?  (Patrick Hatcher <PHatcher@macys.com>)
Ответы Re: Trigger question: ROW or STATEMENT?  (Patrick Hatcher <PHatcher@macys.com>)
Список pgsql-general
On Wed, Jan 25, 2006 at 02:47:45PM -0800, Patrick Hatcher wrote:
> Would I gain any advantage by changing to it to fire after the insert?

If you're modifying the row then the trigger must fire before the
insert.  An after trigger can abort the operation by raising an
error and it can perform actions like updating another table, but
by the time an after trigger fires it's too late to change the
current row (except via an UPDATE, and then you must beware of
cascading triggers leading to infinite recursion).

You might want to read "Overview of Trigger Behavior" in the
documentation -- it describes the various kinds of triggers
(row/statement and before/after) and when certain types are
appropriate:

http://www.postgresql.org/docs/8.1/interactive/triggers.html#TRIGGER-DEFINITION

The documentation mentions that if you have no specific reason to
use before or after, then before is more efficient.

--
Michael Fuhr

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

Предыдущее
От: Redefined Horizons
Дата:
Сообщение: Re: Wiki Site for the PostgreSQL Newbie
Следующее
От: Chris Velevitch
Дата:
Сообщение: Which table(s) in the catalog define the tables and views?