Re: Triggers - Mailing list pgsql-general

From Tom Lane
Subject Re: Triggers
Date
Msg-id 7414.1029507242@sss.pgh.pa.us
Whole thread Raw
In response to Re: Triggers  (Oliver Elphick <olly@lfix.co.uk>)
Responses Re: Triggers  (Oliver Elphick <olly@lfix.co.uk>)
List pgsql-general
Oliver Elphick <olly@lfix.co.uk> writes:
>> Unfortunately the column is defined as not null so I fear the insert
>> would fail and the trigger never get called. How can I get around this?

> Surely you can use a BEFORE trigger, can't you?

I think we check constraints (including NOT NULL) before firing
triggers.

The simple answer to this is not to use a constraint, but to rely on
insert and update triggers to substitute for a null (or throw an error)
in that column.

            regards, tom lane

pgsql-general by date:

Previous
From: Roj Niyogi
Date:
Subject: Re: Good PL/pgSQL ressources>
Next
From: Jean-Christian Imbeault
Date:
Subject: Re: Triggers