Re: DEFERRABLE NOT NULL constraint - Mailing list pgsql-general

From Alban Hertroys
Subject Re: DEFERRABLE NOT NULL constraint
Date
Msg-id CAF-3MvMGGTHT4w76etNNkQtSNj423si7qwn=sB1wTiT8BHZY2Q@mail.gmail.com
Whole thread Raw
In response to Re: DEFERRABLE NOT NULL constraint  (Bèrto ëd Sèra <berto.d.sera@gmail.com>)
List pgsql-general
On 5 February 2013 14:20, B=E8rto =EBd S=E8ra <berto.d.sera@gmail.com> wrot=
e:

> Hi Chris,
>
> > I don't see
> > any reason to create a record with a NULL and then replace that NULL
> > before committing. Sort out program logic first; then look to the
> > database.
>
> I beg to differ here. Say you have a set of business rules that
> rigidly defines how that field must be made AND the data on which it
> is based is not visible to the user who does the insert. At this point
> you need "something" to generate that value on the fly for the user
> (calling a procedure from a before insert trigger).


You need that "something" either way, whether you supply it before the
record is inserted or after. Stuff like that is best done as database
logic, by means of a trigger or rule.

I have to admit that I don't know off the top of my head whether a NOT NULL
constraint fires before ON INSERT triggers or after and I don't have access
to PG from here to check that.
If that's the problem, then you might need to put a RULE in place instead
of an ON BEFORE INSERT trigger. Is that what your complaint boils down to?

--=20
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.

pgsql-general by date:

Previous
From: Andreas Joseph Krogh
Date:
Subject: Re: DEFERRABLE NOT NULL constraint
Next
From: Albe Laurenz
Date:
Subject: Re: tablespace directories