Re: Need "InBetween" (not just Before and After) Trigger - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Need "InBetween" (not just Before and After) Trigger
Date
Msg-id 20010113161647.B28414@wolff.to
Whole thread Raw
In response to Need "InBetween" (not just Before and After) Trigger  (Matt Doucleff <matt@digitalfountain.com>)
List pgsql-general
On Sat, Jan 13, 2001 at 01:23:27PM -0800,
  Matt Doucleff <matt@digitalfountain.com> wrote:
>
> If I use a "before" trigger, the constraints are checked after I've already
> performed my action.  Thus I have performed my action yet no row is inserted
> (which is inconsistent).
>
> If I use an "after" trigger, the constraints are checked first.  If the row is
> inserted, I attempt to perform my action.  If my action fails, then I have an
> inserted row but no action, which is also inconsistent.
>
> The only solution I've developed involves a duplicate table and a transaction.

I think what you want to do is defer constraint checking until the end of
a transaction. You can make a constraint deferable and make the default for
it to be checked at the end of a transaction instead of immediately after
a change.

pgsql-general by date:

Previous
From: Matt Doucleff
Date:
Subject: Need "InBetween" (not just Before and After) Trigger
Next
From: Uro Gruber
Date:
Subject: Compare dates.