Re: Re: Date of creation and of change - Mailing list pgsql-sql

From Tom Lane
Subject Re: Re: Date of creation and of change
Date
Msg-id 2205.967212888@sss.pgh.pa.us
Whole thread Raw
In response to Re: Date of creation and of change  (Andreas Tille <tillea@rki.de>)
Responses Re: Date of creation and of change  (Andreas Tille <tillea@rki.de>)
List pgsql-sql
Andreas Tille <tillea@rki.de> writes:
>> NEW.ChangedAt := timestamp(''now'');

> This avoids the error message, but doesn't have any effect to the value
> of ChangedAt.  It just remains the same as CreatedAt :-(.

I think you are getting burnt by premature constant folding --- see
nearby discussion of how to define a column default that gives the
time of insertion.  You need to write this asNEW.ChangedAt := now();
to prevent the system from reducing timestamp('now') to a constant
when the function is first executed.
        regards, tom lane


pgsql-sql by date:

Previous
From: hlefebvre
Date:
Subject: Re: Re: Date of creation and of change
Next
From: Andreas Tille
Date:
Subject: Re: Date of creation and of change