Re: SQL BEFORE puzzle
Date: Tue, 5 Aug 2008 06:35:26 -0700 (PDT)
Message-ID: <a8258cc4-256e-41ad-bf46-c55fec084576_at_34g2000hsh.googlegroups.com>
On Aug 4, 4:32 pm, Bob Badour <bbad..._at_pei.sympatico.ca> wrote:
> I would expect both the BEFORE and AFTER triggers to have a view of both
> the before and after images of the data. I don't really see the need for
> before and after triggers. Perhaps I am just missing it.
I think it's largely for practical reasons.
An AFTER trigger operates on a row that has already been
physically placed somewhere in the table/index. If the trigger
wants to alter a key value, the row probably has to move,
and you end up with physical storage issues. BEFORE
triggers avoid this, so they are preferred if part of the
action is to calculate or update primary or secondary
key columns.
Of course this is all implementation dependent, but
I suspect most implementations would work that way.