Re: Unexpected Statement Caching with CURRENT_TIMESTAMP - Mailing list pgsql-jdbc

From Markus Schaber
Subject Re: Unexpected Statement Caching with CURRENT_TIMESTAMP
Date
Msg-id 44DC4002.60208@logix-tt.com
Whole thread Raw
In response to Unexpected Statement Caching with CURRENT_TIMESTAMP  ("Nicholas E. Wakefield" <nwakefield@KineticNetworks.com>)
List 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

pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: SQL query never ends
Next
From: "James Im"
Date:
Subject: Re: SQL query never ends