如何在where子句中将整数列表指定为oracle命令参数的参数值? [英] How to assign a list of integers as the parameter value for an oracle command parameter in the where clause ?
问题描述
我有一个类似
的查询
从tablename中选择*其中id为(:ids);
我想分配一个列表以上参数的整数:ids。
我使用ODP.Net和C#。
代码片段将是这样的
const String sql =从tablename中选择*其中id为(:ids); <使用(OracleCommand cmd = new OracleCommand(sql,dbc)){
cmd.Parameters.Add(:ids,OracleDbType.Int64, 12,Ids,ParameterDirection.Input);
使用(OracleDataReader rdr = cmd.ExecuteReader()){
}
}
但它抛出了一些错误......
有人可以帮忙吗?
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 ?
推荐答案
做一件事
将所有整数列表形成一个由逗号(,)分隔的字符串,并将字符串作为参数传递。 />
希望这可以帮到你
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
这篇关于如何在where子句中将整数列表指定为oracle命令参数的参数值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!