Re: Unexpected Statement Caching with CURRENT_TIMESTAMP

From: Markus Schaber <schabi(at)logix-tt(dot)com>
To: "Nicholas E(dot) Wakefield" <nwakefield(at)KineticNetworks(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Unexpected Statement Caching with CURRENT_TIMESTAMP
Date: 2006-08-11 08:29:54
Message-ID: 44DC4002.60208@logix-tt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi, Nicolas,

Nicholas E. Wakefield wrote:
> I'm executing 'SELECT CURRENT_TIMESTAMP' from a statement object with
> auto commit off and prepare threshold set to 1. I'm finding that the
> result comes back the same for after multiple calls and instantiations
> of the statement object(The same happens for a prepared statement).
> However this does not occur when I perform a commit before or after
> every call.
>
> Is this expected behaviour?

Yes, it's expected, intended and documented in the PostgreSQL docs:
http://www.postgresql.org/docs/8.1/static/functions-datetime.html

SELECT timeofday(); returns a clock that advances even during
transactions. As it returns a textual representation, you may need to
cast it to a timestamp in some query contexts, though:

select timeofday(); -- returns text
select timeofday()::timestamp; -- returns timestamp - postgresql variant
select CAST(timeofday() AS timestamp) ; -- returns timestamp in sql99

HTH,
Markus
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS

Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message James Im 2006-08-11 11:55:29 Re: SQL query never ends
Previous Message Oliver Jowett 2006-08-11 02:03:56 Re: SQL query never ends