Search Postgresql Archives

Re: DEFERRABLE NOT NULL constraint

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5 February 2013 14:20, Bèrto ëd Sèra <berto.d.sera@xxxxxxxxx> 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 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?

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux