Re: Problems with NEW.* in triggers - Mailing list pgsql-sql

From Tom Lane
Subject Re: Problems with NEW.* in triggers
Date
Msg-id 26587.1067986114@sss.pgh.pa.us
Whole thread Raw
In response to Problems with NEW.* in triggers  (Jamie Lawrence <postgres@jal.org>)
Responses Re: Problems with NEW.* in triggers  (Jamie Lawrence <postgres@jal.org>)
List pgsql-sql
Jamie Lawrence <postgres@jal.org> writes:
> I had thought that if moddate isn't included in an insert or update,
> that it would be null in the NEW context,

No, it would be whatever the value to be assigned to the column would
be, if the trigger were not present.  In particular, during an UPDATE
it's going to contain the old value of the field.  In an INSERT it would
be whatever the column's default value is.

I am not sure what your intention is here.  If you want the trigger to
force the field to current time, it can certainly do that.  If you want
the user to control whether the field is updated, why do you need a
trigger at all?
        regards, tom lane


pgsql-sql by date:

Previous
From: Jamie Lawrence
Date:
Subject: Problems with NEW.* in triggers
Next
From: Josh Berkus
Date:
Subject: Re: Problems with NEW.* in triggers