From: | Patrick Hatcher <PHatcher(at)macys(dot)com> |
---|---|
To: | Michael Fuhr <mike(at)fuhr(dot)org> |
Cc: | Doug McNaught <doug(at)mcnaught(dot)org>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Trigger question: ROW or STATEMENT? |
Date: | 2006-01-26 14:56:49 |
Message-ID: | OFDD945EE0.02621A62-ON88257102.005213A6-88257102.00521B2E@FDS.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
that answered my question.
Thanks everyone
Patrick Hatcher
Development Manager Analytics/MIO
Macys.com
Michael Fuhr
<mike(at)fuhr(dot)org>
To
01/25/06 07:52 PM Patrick Hatcher
<PHatcher(at)macys(dot)com>
cc
Doug McNaught <doug(at)mcnaught(dot)org>,
pgsql-general(at)postgresql(dot)org
Subject
Re: [GENERAL] Trigger question:
ROW or STATEMENT?
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
From | Date | Subject | |
---|---|---|---|
Next Message | Dick Kniep | 2006-01-26 15:06:57 | Re: Connected user in a triggerfunction |
Previous Message | filip_stoklosa | 2006-01-26 14:04:03 | locale - polish, poland |