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

From Chris Angelico
Subject Re: DEFERRABLE NOT NULL constraint
Date
Msg-id CAPTjJmqd+4XGRnzypmkSL36OoscsCN+4W9zCf5AztFiU_TRudw@mail.gmail.com
Whole thread Raw
In response to Re: DEFERRABLE NOT NULL constraint  (Bèrto ëd Sèra <berto.d.sera@gmail.com>)
Responses Re: DEFERRABLE NOT NULL constraint  (Bèrto ëd Sèra <berto.d.sera@gmail.com>)
List pgsql-general
On Wed, Feb 6, 2013 at 12:20 AM, B=E8rto =EBd S=E8ra <berto.d.sera@gmail.co=
m> wrote:
> 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 still need
> your field to be NOT NULL, though. Because it happens to be... the PK
> :)

Why do that as a trigger, then? Why not simply call a procedure that
generates the value and inserts it?

ChrisA

pgsql-general by date:

Previous
From: Bèrto ëd Sèra
Date:
Subject: Re: DEFERRABLE NOT NULL constraint
Next
From: Bèrto ëd Sèra
Date:
Subject: Re: DEFERRABLE NOT NULL constraint