Re: PreparedStatement error for date parameter with overlaps

From: Simon Mitchell <simon(at)jseb(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: PreparedStatement error for date parameter with overlaps
Date: 2011-05-31 06:01:35
Message-ID: BANLkTinJBQFH5exg7r-8VxHc+u4L_m+H9w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Bingo

thanks guys, this works fine, obviously I had no idea what i was doing,
no need to run the date function on a date.
SELECT (CAST(? AS date), ?::date) OVERLAPS (date(?), date(?)) works fine.

So from what I understand using the date function in jdbc stuff requires
brackets like most functions do,
but the psql is happy for me to use the date function with or without
brackets.
Postgresql docs examples seem to be all with out brackets.

On Tue, May 31, 2011 at 15:27, Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>wrote:

> On 31/05/11 11:12, Simon Mitchell wrote:
>
> > Both ?::date and CAST(? AS date) fail in java.
> >
> > ?::date works fine in psql, but CAST(? AS date) fails in psql.
> >
> > SELECT (date CAST('2001-02-16' AS date), date ('2001-12-21')) OVERLAPS
> > (date ('2001-10-30'), date ('2002-10-30'));
> > ERROR: syntax error at or near "CAST"
>
> You wrote:
>
> SELECT (date CAST('2001-02-16' AS date) ...
> ^^^^
> whoops
>
> you should write:
>
> SELECT (CAST('2001-02-16' AS date) ...
>
> See how that goes.
>
> --
> Craig Ringer
>

--
simon

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Craig Ringer 2011-05-31 06:41:36 Re: PreparedStatement error for date parameter with overlaps
Previous Message Craig Ringer 2011-05-31 05:27:48 Re: PreparedStatement error for date parameter with overlaps