Re: setting PreparedStatement parameter using "at time zone interval ?"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Matt Magoffin" <postgresql(dot)org(at)msqr(dot)us>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: setting PreparedStatement parameter using "at time zone interval ?"
Date: 2007-12-19 15:48:45
Message-ID: 23204.1198079325@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

"Matt Magoffin" <postgresql(dot)org(at)msqr(dot)us> writes:
> I'm using the latest 8.3 development driver against an 8.3 database. I
> thought back in 8.1 I used to be able to use a PreparedStatement that
> included something like
> ... date(l.created AT TIME ZONE INTERVAL ?)

That might've worked back before the driver did real prepared
statements. It's invalid syntax though, because typename before the
constant works only for simple literal string constants. You got away
with it when the driver interpolated parameter values into the query as
string literals, but you can't do it anymore.

?::interval (or the full-blown CAST syntax) is the right way.

See
http://developer.postgresql.org/pgdocs/postgres/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS
particularly 4.1.2.5.

regards, tom lane

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Daniel Migowski 2007-12-19 15:50:32 Re: TypeInfoCache
Previous Message Daniel Migowski 2007-12-19 15:45:15 Re: TypeInfoCache