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: Parameterizing queries with SQL "IN" clauses

Re: Parameterizing queries with SQL "IN" clauses

From: C. Ferguson <c_ferguson_at_rationalconcepts.com>
Date: Fri, 20 Oct 2000 02:19:51 GMT
Message-ID: <39EFAC0F.2D4EB6C3@rationalconcepts.com>

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

Original text of this message

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