pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedProblem with now() in function pgsql
2+ messages / 2 participants
[nested] [flat]
* Problem with now() in function pgsql
@ 2008-04-05 17:46 luke.78@libero.it <luke.78@libero.it>
2008-04-05 17:59 ` Re: Problem with now() in function pgsql Adrian Klaver <aklaver@comcast.net>
0 siblings, 1 reply; 2+ messages in thread
From: luke\.78\@libero\.it @ 2008-04-05 17:46 UTC (permalink / raw)
To: pgsql-sql
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.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Problem with now() in function pgsql
2008-04-05 17:46 Problem with now() in function pgsql luke.78@libero.it <luke.78@libero.it>
@ 2008-04-05 17:59 ` Adrian Klaver <aklaver@comcast.net>
0 siblings, 0 replies; 2+ messages in thread
From: Adrian Klaver @ 2008-04-05 17:59 UTC (permalink / raw)
To: pgsql-sql; +Cc: luke.78@libero.it
On Saturday 05 April 2008 10:46 am, luke.78@libero.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@comcast.net
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2008-04-05 17:59 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-04-05 17:46 Problem with now() in function pgsql luke.78@libero.it <luke.78@libero.it>
2008-04-05 17:59 ` Adrian Klaver <aklaver@comcast.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox