码迷,mamicode.com
首页 > 数据库 > 详细

oracle in表达式参数支持最大上限1000个

时间:2017-10-25 11:28:26      阅读:1583      评论:0      收藏:0      [点我收藏+]

标签:region   har   acl   com   query   private   ora   ++   ring   

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

oracle in表达式参数支持最大上限1000个

标签:region   har   acl   com   query   private   ora   ++   ring   

原文地址:http://www.cnblogs.com/eternal1025/p/7727099.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!