Skip site navigation (1) Skip section navigation (2)

Re: JDBC 7.4 to 8.1 regression problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Carsten Friedrich" <carsten(at)dtecht(dot)com(dot)au>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: JDBC 7.4 to 8.1 regression problem
Date: 2006-07-14 16:15:01
Message-ID: 21246.1152893701@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-jdbc
"Carsten Friedrich" <carsten(at)dtecht(dot)com(dot)au> writes:
> I use the following prepared statement:

> 	final static String SQL= "SELECT " +
> [...]
> 	  " WHERE " +
> [...]
> 	+ "   AND service_date <= ?" +
> 	  " and service_date > date ? - interval '365 days'; "

The above is broken code, and always has been: the fact that it failed
to malfunction back in 7.4 was purely accidental.  You can only use the
syntax "typename literal" with a literal constant.  Instead of "date ?"
use "?::date", or if you want to be fully SQL-spec-compliant write it
out as "CAST(? AS date)".

Actually, it'd probably be better to use "date_trunc('day', ?)" anyway,
since that's what you're trying to achieve with the cast.

			regards, tom lane

In response to

pgsql-jdbc by date

Next:From: Jennie BrowneDate: 2006-07-18 13:11:09
Subject: PreparedStatment Memory Size
Previous:From: Carsten FriedrichDate: 2006-07-14 02:01:28
Subject: JDBC 7.4 to 8.1 regression problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group