Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Variable Arg Lists to PreparedStatements

Re: Variable Arg Lists to PreparedStatements

From: Yakov <yfain_at_hotmail.com>
Date: 20 Sep 2004 19:21:53 -0700
Message-ID: <b04e2170.0409201821.75a41751@posting.google.com>


robertbrown1971_at_yahoo.com (Robert Brown) wrote in message news:<240a4d09.0409200852.1711430a_at_posting.google.com>...
> Is there a way to use PreparedStatements (or bind variables) with SQL
> statements that have a variable number of arguments. For example, I
> have an array of IDs for employees of a certain type and I want to
> have a PreparedStatement retrieve all of them in a single SQL call.
>
> SELECT FROM employees WHERE employee_type = ? employee_id in
> (?,?,?,...,?)
>
> It seems at least in Java that PreparedStatements can only take a
> fixed number of arguments?
>

Srting sql = "SELECT FROM employees WHERE employee_type = ? employee_id in(";

When you have all your IDs in the array, concatenate a required number of the question marks in a loop like for(int i=0;i<myArray.length;i++)...

Set param values from the array in a similar loop

Regards,
Yakov Received on Mon Sep 20 2004 - 21:21:53 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US