From: Oliver Jowett <oliver@opencloud.com>
To: Matt Magoffin <postgresql.org@msqr.us>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: INTERVAL parameter in PreparedStatement worked in 7.4
Date: Fri, 28 Oct 2005 13:29:21 +1300
Message-ID: <436170E1.6000909@opencloud.com> (raw)
In-Reply-To: <50387.219.89.94.58.1130457365.squirrel@msqr.us>
References: <50387.219.89.94.58.1130457365.squirrel@msqr.us>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: oliver@opencloud.com, postgresql.org@msqr.us
Subject: Re: INTERVAL parameter in PreparedStatement worked in 7.4
In-Reply-To: <436170E1.6000909@opencloud.com>
References: <50387.219.89.94.58.1130457365.squirrel@msqr.us> <436170E1.6000909@opencloud.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox