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
> 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