On Tue, 26 Oct 2004, Alexey Yudichev wrote:
> Ah, except that thing with "at time zone":
>
> select now() at time zone ('-02:00'::interval);
> works OK in psql console;
>
> but with JDBC
> select now() at time zone (?::interval)
> with setString(1, '-02:00')
Right, setString was recently changed from typing things as text to
varchar. This means you need (?::text::interval) now, at least for this
example on 7.4. Another solution would be to use the PGobject type
PGInterval via something like:
SELECT now() AT TIME ZONE ?
setObject(1, new org.postgresql.util.PGInterval("-02:00"));
I actually forget if this will work at the moment, but if not it will
eventually because of a patch from Oliver Jowett. This avoids the pg
specific cast in your sql code, but adds pg specific code at compile time.
I imagine it might be more future proof though.
Kris Jurka