Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a query like
Select * from tablename where id in (:ids);

I want to assign a list of integers for the above parameter :ids.
I am using the ODP.Net with C#.

The code snippet will be something like this

const String sql = Select * from tablename where id in (:ids);

using(OracleCommand cmd = new OracleCommand(sql, dbc)) {
cmd.Parameters.Add(:ids, OracleDbType.Int64, 12, Ids , ParameterDirection.Input);
using(OracleDataReader rdr = cmd.ExecuteReader()) {
}
}


But its throwing some errors...

Can anybody please help on this ?
Posted

1 solution

Do one thing
Form all list of integers as a string seperated by comma(,) and the pass the string as paramter.
Hope this may help you
 
Share this answer
 
Comments
Linto Leo Tom 25-Feb-14 1:16am    
thanks Ravi.
this is fine.
is there any other way to do this ?
this is like constructing the quey dynamically.
what i want to know is, is it possible to have a single parameter which can can be replaced be a list of values ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900