Weird ILIKE behavior

From: "Keith C(dot) Klopfer" <k(dot)klopfer(at)comcast(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Weird ILIKE behavior
Date: 2004-01-12 07:36:09
Message-ID: r02010000-1032-FDEE948844D111D8BD47000393BA4D6A@[10.0.1.7]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello,

I'm driving myself crazy trying to understand some weird behavior with a SELECT using ILIKE. I'm
using a prepared statement:

String sql = "SELECT * FROM business WHERE name ILIKE ? ORDER BY name;";
PreparedStatement stmt = conn.prepareStatement(sql);
String s = "%" + query + "%";
stmt.setString(1, s);

I have a business with name: "PETCO - Beaverton" (this has been confirmed numerous times!)

When the variable query = "petco", it doesn't match. When query is "p", "pe", "pet", "etc" it matches
fine. It also doesn't match when query is "petc" or "tco". Case doesn't seem to have an effect.
Running from psql matches all of the above, but when used with the java/jdbc code above, it fails in
the above few cases (and the most important one - "petco"!). I've confirmed using print statements
that query contains the "correct" string immediately before the String s = line.

Any ideas? I can't seem to find any more examples of this weird behaviour with other business
names...

Thanks,

Keith K.

Browse pgsql-jdbc by date

  From Date Subject
Next Message John Sidney-Woollett 2004-01-12 08:01:56 Re: jdbc pooling question
Previous Message Ramin Rad 2004-01-12 01:33:08 Re: JDBC parse error with preparedStatement!