|
Thanks Sarah,
I was hopeful that it could be done using the ?, but good to have
this option.
regards
James O'Sullivan
Senior Technical Consultant
email: josulli4@xxxxxxx
Office: +44 1252 536681
Fax: +44 1252 534022
www: www.csc.com
Based at: Tower 2, Floor 2, Royal Pavilion, Wellesley Road, Aldershot,
Hampshire, GU11 1PZ
CSC Corporation Limited: No. 1812179.
All registered office addresses: Royal Pavilion, Wellesley Road, Aldershot,
Hampshire, GU11 1PZ. Registered in England.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery. NOTE: Regardless of content, this e-mail shall not operate to
bind CSC to any order or other contract unless pursuant to explicit written
agreement or government initiative expressly permitting the use of e-mail
for such purpose.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sarah Poger
Gladstone
<listmember@glads To
tone.info> Java Programming on and around the
Sent by: iSeries / AS400
java400-l-bounces <java400-l@xxxxxxxxxxxx>
@midrange.com cc
Subject
26/01/2006 15:12 Re: JDBC - Setting Values on
PreparedStatement
Please respond to
Java Programming
on and around the
iSeries / AS400
<java400-l@midran
ge.com>
I had to do something similar where I didn't know in advance how many
variables would be in the IN clause.
How I solved my issue was to not use ? in my prepared statement.
For example:
String langs = "'" + lang1 + "' , " + "'" + lang2 + "'";
PreparedStatement pstmt = con.prepareStatement("SELECT * FROM ERORPF WHERE
ERORLANG IN (" + langs + ")" );
HTH,
Sarah
On 1/26/06, James O'Sullivan <josulli4@xxxxxxx> wrote:
>
>
>
>
> Hi All,
> I have had a tour around the Net and can't seem to find an
> answer/example of this.
>
> Have a simple SQL statement
> SELECT * FROM ERORPF WHERE ERORLANG IN ('E', 'N', 'D')
> The contents of the IN predicate can vary from 1 to 10 items, hence my
> question.
>
> I set this in a PreparedStatement
>
> PreparedStatement pstmt = con.prepareStatement("SELECT * FROM ERORPF
WHERE
> ERORLANG IN (?)");
>
> But when it came to replacing the ? with the required values, I hit my
> problem.
> I tried (perhaps optimistically) just to see if it would accept
parameters
> in the following format, but no joy.
>
> String langs = "'" + lang1 + "' , " + "'" + lang2 + "'";
> setString(1, langs);
>
> How can you pass a variable amount of values to the IN predicate?
>
>
> regards
>
>
> James O'Sullivan
> Senior Technical Consultant
> email: josulli4@xxxxxxx
> Office: +44 1252 536681
> Fax: +44 1252 534022
> www: www.csc.com
> Based at: Tower 2, Floor 2, Royal Pavilion, Wellesley Road, Aldershot,
> Hampshire, GU11 1PZ
>
> CSC Corporation Limited: No. 1812179.
> All registered office addresses: Royal Pavilion, Wellesley Road,
Aldershot,
> Hampshire, GU11 1PZ. Registered in England.
>
>
>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> This is a PRIVATE message. If you are not the intended recipient, please
> delete without copying and kindly advise us by e-mail of the mistake in
> delivery. NOTE: Regardless of content, this e-mail shall not operate to
> bind CSC to any order or other contract unless pursuant to explicit
written
> agreement or government initiative expressly permitting the use of e-mail
> for such purpose.
>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
> --
> This is the Java Programming on and around the iSeries / AS400
(JAVA400-L) mailing list
> To post a message email: JAVA400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/java400-l
> or email: JAVA400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/java400-l.
>
>
--
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.