pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: j.random.programmer <javadesigner@yahoo.com>
To: Dave Cramer <pg@fastcrypt.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: PreparedStatements, LIKE and the % operator
Date: Fri, 2 Feb 2007 21:59:26 -0800 (PST)
Message-ID: <26855.31012.qm@web32014.mail.mud.yahoo.com> (raw)
In-Reply-To: <37697F6B-C1F1-448D-AFCA-E7C463FBA283@fastcrypt.com>

Hi:
 
> Craps out how ?
> 
> bar = like %?%

That was a typo. Sorry. I wasn't using '=' at all. 
 
> 
> bar like '%?%'
> is closer to the correct syntax

That's what I was doing. The driver gives this error:

-----------------------------
org.postgresql.util.PSQLException: The column index is
out of range: 1, number of columns: 0.
	at
org.postgresql.core.v3.SimpleParameterList.bind(SimpleParameterList.java:52)
	at
org.postgresql.core.v3.SimpleParameterList.setStringParameter(SimpleParameterList.java:117)
	at
org.postgresql.jdbc2.AbstractJdbc2Statement.bindString(AbstractJdbc2Statement.java:2118)
	at
org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1241)
	at
org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1227)
....etc........
--------------------------------

I hacked around a bit and finally said:

.... bar like ? and foo like ?

ps.setString(1, "%" + myvalue + "%")
ps.setString(2, "%" + my_other_value + "%")

That worked but it's a bit counter-intuitive. 

Best regards,
--j


 
____________________________________________________________________________________
Don't get soaked.  Take a quick peak at the forecast
with the Yahoo! Search weather shortcut.
http://tools.search.yahoo.com/shortcuts/#loc_weather



view thread (5+ messages)  latest in thread

Message-ID: <26855.31012.qm@web32014.mail.mud.yahoo.com>
Permalink:  ../26855.31012.qm@web32014.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/26855.31012.qm@web32014.mail.mud.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: javadesigner@yahoo.com, pg@fastcrypt.com
  Subject: Re: PreparedStatements, LIKE and the % operator
  In-Reply-To: <26855.31012.qm@web32014.mail.mud.yahoo.com>
  References: <37697F6B-C1F1-448D-AFCA-E7C463FBA283@fastcrypt.com> <26855.31012.qm@web32014.mail.mud.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox