Re: TRIGGER BEFORE INSERT - Mailing list pgsql-general

From Adrian Klaver
Subject Re: TRIGGER BEFORE INSERT
Date
Msg-id 200701111226.30559.aklaver@comcast.net
Whole thread Raw
In response to Re: TRIGGER BEFORE INSERT  (Rafal Pietrak <rafal@zorro.isa-geek.com>)
Responses Re: TRIGGER BEFORE INSERT
List pgsql-general
On Thursday 11 January 2007 10:26 am, Rafal Pietrak wrote:
> On Thu, 2007-01-11 at 15:10 +0100, Alban Hertroys wrote:
> > Rafal Pietrak wrote:
> > > Hi!
> > >
> > > I'm re-posting this message again in hope someone would have a look at
> > > the case again.   .. it's pending.
> >
> > You were given a solution; defer the foreign key constraint.
>
> Well. I were, but probably I'm doing something wrong with 'deferring the
> trigger'. When I put:

What previous posters have said is that you need to defer the FK. So you need
to change your table definition from:
CREATE TABLE test_utarg(tm timestamp not null, nic int, amount int not
null, dnia int references test_days(id));
to:
CREATE TABLE test_utarg(tm timestamp not null, nic int, amount int not
null, dnia int references test_days(id) INITIALLY DEFERRED);
per Toms suggestion. This eliminates the need for the SET CONSTRAINTS DEFERRED
statement.



--
Adrian Klaver
aklaver@comcast.net

pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: ORDER BY col is NULL in UNION causes error?
Next
From: Bruno Wolff III
Date:
Subject: Re: generate_series with month intervals