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