oracle in表达式参数支持最大上限1000个
方法是拆分为多个 col in ... or col in ...
#region 解决大于1000的问题 private String getSubQuery(String riskIds) { int strParaLen = riskIds.Length; string subQ = string.Empty; subQ = subQ + "("; if (!"".Equals(riskIds) && null != riskIds) { String[] riskIDs = riskIds.Split(','); if (riskIDs.Length > 1000) { for (int i = 0; i < riskIDs.Length; i++) { if ((i + 1) % 1000 == 0) { String temp = subQ.Substring(0, subQ.Length - 1); subQ = string.Empty; subQ = subQ + temp; subQ = subQ + ") OR TO_CHAR(ZFID) IN ("; subQ = subQ + riskIDs[i] + ","; } else { subQ = subQ + riskIDs[i] + ","; } } string s_temp = subQ.Substring(0, subQ.Length - 1); subQ = string.Empty; subQ = subQ + s_temp; subQ = subQ + ")"; } else { subQ = subQ + riskIds; subQ = subQ + ")"; } } else { subQ = subQ + ")"; } return subQ.ToString(); }
传入参数是一个"1,2,3,4"形式的string,分隔符",";
借鉴了 http://eric-yan.iteye.com/blog/1942713