pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Matt Magoffin <postgresql.org@msqr.us>
To: pgsql-jdbc@postgresql.org
Subject: Re: INTERVAL parameter in PreparedStatement worked in 7.4
Date: Thu, 27 Oct 2005 17:02:14 -0700 (PDT)
Message-ID: <50418.219.89.94.58.1130457734.squirrel@msqr.us> (raw)
In-Reply-To: <50387.219.89.94.58.1130457365.squirrel@msqr.us>
References: <50387.219.89.94.58.1130457365.squirrel@msqr.us>

I forgot to add that the 8 driver throws an exception when trying to parse
the statement with the positional parameter:

java.sql.SQLException: ERROR: syntax error at or near "$1"

-- m@

> Hello,
>
> 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?
>
> The query does work in the 8 driver if the ? is explicitly part of the
> query, i.e. not a positional parameter, like this:
>
> select * from users users where users.createdDate < (CURRENT_DATE -
> INTERVAL '14 DAYS')
>
> Any help much appreciated,
> m@




view thread (4+ messages)  latest in thread

Message-ID: <50418.219.89.94.58.1130457734.squirrel@msqr.us>
Permalink:  ../50418.219.89.94.58.1130457734.squirrel@msqr.us/
Also on:    postgresql.org/message-id/50418.219.89.94.58.1130457734.squirrel@msqr.us

 · 

reply

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: postgresql.org@msqr.us
  Subject: Re: INTERVAL parameter in PreparedStatement worked in 7.4
  In-Reply-To: <50418.219.89.94.58.1130457734.squirrel@msqr.us>
  References: <50387.219.89.94.58.1130457365.squirrel@msqr.us> <50418.219.89.94.58.1130457734.squirrel@msqr.us>

* 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