Re: Problem with now() in function pgsql

From: Adrian Klaver <aklaver(at)comcast(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Cc: luke(dot)78(at)libero(dot)it
Subject: Re: Problem with now() in function pgsql
Date: 2008-04-05 17:59:51
Message-ID: 200804051059.51195.aklaver@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Saturday 05 April 2008 10:46 am, luke(dot)78(at)libero(dot)it wrote:
> Hi,
> I have a problem in a function pgsql with Reading TIMESTAMP calling the
> function now() the problem is this:
> At the begin of function I read timestamp...
> select now() into TS_BEGIN;
>
> the function execute some statement...
>
> Many seconds after I reread the timestamp
> select now() into TS_END;
>
> and TS_BEGIN is identical TS_END!!!
>
> Can anyone help me?
>
> Thanks in advance.
>
> Luke.
You want to use clock_timestamp() or equivalent not now(). As you found out
now() fixes the time at the start of the transaction and does not change,
clock_timestamp() does. See URL below for a more complete explanation:

http://www.postgresql.org/docs/8.2/interactive/functions-datetime.html
--
Adrian Klaver
aklaver(at)comcast(dot)net

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message John Reeve 2008-04-07 03:18:24 Re: Sequential non unique IDs
Previous Message luke.78@libero.it 2008-04-05 17:46:55 Problem with now() in function pgsql