Re: PreparedStatement error for date parameter with overlaps

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Simon Mitchell <simon(at)jseb(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: PreparedStatement error for date parameter with overlaps
Date: 2011-05-31 01:52:13
Message-ID: 14646.1306806733@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Simon Mitchell <simon(at)jseb(dot)com> writes:
> // some bad code
> sqlText = "SELECT (date ?, date ?) OVERLAPS (date ?, date ?);";

That's not going to work, because the syntax
date 'something'
only works for literal constants, and a ? marker is not a literal constant.
You could try
?::date
or
CAST(? AS date)
if you prefer to avoid Postgres-specific syntax. Even better, don't use
setString --- that's really only meant for parameters that are of string
datatypes.

regards, tom lane

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Simon Mitchell 2011-05-31 03:12:12 Re: PreparedStatement error for date parameter with overlaps
Previous Message Dave Cramer 2011-05-31 01:47:58 Re: PreparedStatement error for date parameter with overlaps