Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / September 2006

Tip: Looking for answers? Try searching our database.

Multiple values for IN keyword of WHERE clause don't appear to work with InfxPreparedStatement

Thread view: 
mlapidge - 04 Sep 2006 14:28 GMT
Any views on the following behaviour would be appreciated. I am using

INFORMIX-OnLine 7.31.UD7
IBM Informix JDBC Driver for IBM Informix Dynamic Server 2.21.JC5

Some code....

PreparedStatement ifxStmt2 = ifxCxn.preparedStatement("select iddoc
from corrapp where identity IN (?));

This works - with only one value in the list of IN values to bind...

ifxStmt2.setString(bind, "'000000010'");
ifxStmt2.execute();
rSet = ifxStmt2.getResultSet();
while (rSet.next()) {
this code is executed
}

In the above case a ResultSet object with a number of rows is returned.

However, if I add a second value to the list of IN values (below I just
duplicate the first value and expect the same set of results) an empty
ResultSet object is returned (no exceptions raised)...

ifxStmt2.setString(bind, "'000000010','000000010");
ifxStmt2.execute();
rSet = ifxStmt2.getResultSet();
while (rSet.next()) {
this code is NOT executed
}

This same second version of the query executed on the server works OK.
The identity column type is CHAR(12) but I have investigated issues
with padding using "'   000000010" or indeed "'000000010   '" for the
IN list values to no avail.

Many thanks,

Mark
Arne Vajhøj - 04 Sep 2006 17:32 GMT
> Any views on the following behaviour would be appreciated. I am using
>
[quoted text clipped - 9 lines]
>
> ifxStmt2.setString(bind, "'000000010'");

> However, if I add a second value to the list of IN values (below I just
> duplicate the first value and expect the same set of results) an empty
> ResultSet object is returned (no exceptions raised)...
>
> ifxStmt2.setString(bind, "'000000010','000000010");

I would not expect it to work.

? reprensents one value.

"'000000010'" which I would write as "000000010" is
one value.

"'000000010','000000010'" is one value too - just with
a comma in.

You should either:
  - add the same number of ?'s as you have values
  - use oldfashioned risky values directly in SQL
  - redesign so you do not need it

Arne
mlapidge - 04 Sep 2006 19:09 GMT
Thanks Arne,
I tested with your reply in mind and now I know what the problem is I
can get on and fix it.

> > Any views on the following behaviour would be appreciated. I am using
> >
[quoted text clipped - 32 lines]
>
> Arne
mlapidge - 04 Sep 2006 20:02 GMT
Thanks Arne,
I tested with your reply in mind and now I know what the problem is I
can get on and fix it.

> > Any views on the following behaviour would be appreciated. I am using
> >
[quoted text clipped - 32 lines]
>
> Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.