Re: Error selecting constant

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Mat <mat(at)voxmobili(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Error selecting constant
Date: 2008-08-22 23:23:47
Message-ID: 48AF4A83.4060400@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Mat wrote:

> org.springframework.dao.DataRetrievalFailureException: Problem executing
> statement: SELECT '?_?' as result with values [str1, str2]; nested
> exception is org.postgresql.util.PSQLException: The column index is out
> of range: 1, number of columns: 0.

Try "SELECT ? || '_' || ?"

Parameter substitution is not just substitution into the query string,
you can only put ? where it makes sense to have a selfcontained data
value. And it's definitely not going to work inside a string constant,
the driver must interpret that '?' as a literal '?' not a parameter
placeholder!

-O

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message kumar, Anand (Anand) 2008-08-25 05:38:17 ssl support in XA Datasource
Previous Message Daniele Depetrini 2008-08-22 12:11:29 Re: Pooled connections idle timeout