Re: PreparedStatement error for date parameter with overlaps - Mailing list pgsql-jdbc

From Tom Lane
Subject Re: PreparedStatement error for date parameter with overlaps
Date
Msg-id 14646.1306806733@sss.pgh.pa.us
Whole thread Raw
In response to PreparedStatement error for date parameter with overlaps  (Simon Mitchell <simon@jseb.com>)
Responses Re: PreparedStatement error for date parameter with overlaps
List pgsql-jdbc
Simon Mitchell <simon@jseb.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

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: PreparedStatement error for date parameter with overlaps
Next
From: Simon Mitchell
Date:
Subject: Re: PreparedStatement error for date parameter with overlaps