Re: Problems with NEW.* in triggers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jamie Lawrence <postgres(at)jal(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Problems with NEW.* in triggers
Date: 2003-11-04 22:48:34
Message-ID: 26587.1067986114@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Jamie Lawrence <postgres(at)jal(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2003-11-04 22:52:34 Re: Problems with NEW.* in triggers
Previous Message Jamie Lawrence 2003-11-04 22:33:19 Problems with NEW.* in triggers