Re: Re: Date of creation and of change

From: hlefebvre <hlefebvre(at)lexbase(dot)net>
To: Andreas Tille <tillea(at)rki(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL SQL <pgsql-sql(at)hub(dot)org>
Subject: Re: Re: Date of creation and of change
Date: 2000-08-25 15:22:26
Message-ID: 39A68F32.7C781690@lexbase.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Andreas Tille wrote:
>
> On Fri, 25 Aug 2000, Tom Lane wrote:
>
> > 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 as
> > NEW.ChangedAt := now();
> > to prevent the system from reducing timestamp('now') to a constant
> > when the function is first executed.
> This doesn't work, too.
> It just puts allways the constant time when the function was created
> into the database. May be it has to be escaped in somw way??
>
> I don't know how to follow hlefebvre's hint to "put null" into the
> field.

As I said, I was wrong, and Tom is right.

I was suspecting a problem if the field is not used in the query, but
the pb was about the now() function.

> Bay the way: If we once solved the problem it might be a topic for
> the FAQ, perhaps?

IMHO this is a documentation problem.
There is no example about such trigger who will modify data, and 'now'
is described as "transaction time".
also, in date/time function now() is not mentionned
(doc about pgSQL 7.0 on the web site at
http://www.postgresql.org/users-lounge/docs/7.0/user/functions2872.htm)

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jackson Ching 2000-08-25 16:37:57 Getting the result of a query using COUNT(*)
Previous Message Renato De Giovanni 2000-08-25 15:13:59 Re: weird structure