Re: INTERVAL parameter in PreparedStatement worked in 7.4

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Matt Magoffin <postgresql(dot)org(at)msqr(dot)us>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: INTERVAL parameter in PreparedStatement worked in 7.4
Date: 2005-10-28 00:29:21
Message-ID: 436170E1.6000909@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Matt Magoffin wrote:

> I used to use the following style statement with the 7.4 series JDBC driver:
>
> select * from users users where users.createdDate < (CURRENT_DATE -
> INTERVAL ?)
>
> and would set the parameter to a string value of "14 DAYS"
>
> but in the Postgres 8 driver, this query executes but does not seem to
> ever return anything. Is there a better syntax I could use to make this
> work?

"CAST (? AS INTERVAL)" should work.

Or use org.postgresql.util.PGInterval:

stmt.setObject(1, new PGInterval("14 days"));

-O

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Matt Magoffin 2005-10-28 00:36:42 Re: INTERVAL parameter in PreparedStatement worked in
Previous Message Matt Magoffin 2005-10-28 00:02:14 Re: INTERVAL parameter in PreparedStatement worked in 7.4