Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Parameterizing queries with SQL "IN" clauses
Hi Eric,
you will have to build clause in your code
to get something like select * from table1 where id in (?, ?, ?, ?);
if you have 4 ids.
It's not hard to build on a variable length list of ids.
hth,
cindy
Eric Bell wrote:
> I have query that I am calling using JDBC. The query has an "IN" clause in
> it:
>
> select *
> from table1
> where id in (123,234,234,234);
>
> I would like to be able to pass the values in the "IN" clause via a
> parameter, such as:
>
> select *
> from table1
> where id in (?);
>
> Then in my JDBC code I would have:
>
> preparedStatement.setString(1, "123,234,234,234" );
>
> This doesn't work, which doesn't surprise me. But does anybody know a way to
> do this, or do I have to build my IN clause in code?
>
> Thanks
Received on Thu Oct 19 2000 - 21:19:51 CDT