zoukankan      html  css  js  c++  java
  • sql in条件 超过1000字符的处理方法

    1. private string getOracleSQLIn(string[] ids, string field)  
    2.         {  
    3.             int count = Math.Min(ids.Length, 1000);  
    4.             int len = ids.Length;  
    5.             int size = len % count;  
    6.             if (size == 0)  
    7.             {  
    8.                 size = len / count;  
    9.             }  
    10.             else  
    11.             {  
    12.                 size = (len / count) + 1;  
    13.             }  
    14.             StringBuilder builder = new StringBuilder();  
    15.             for (int i = 0; i < size; i++)  
    16.             {  
    17.                 int fromIndex = i * count;  
    18.                 int toIndex = Math.Min(fromIndex + count, len);  
    19.                 string productId = string.Join("','", getArrayValues(fromIndex, toIndex, ids).ToArray());  
    20.                 if (i != 0)  
    21.                 {  
    22.                     builder.Append(" or ");  
    23.                 }  
    24.                 builder.Append(field).Append(" in ('").Append(productId).Append("')");  
    25.             }  
    26.             return " ("+builder.ToString()+") ";  
    27.         }  
    28.   
    29.         public List<string> getArrayValues(int fromindex, int toindex, string[] array)  
    30.         {  
    31.             List<string> listret = new List<string>();  
    32.             for (int i = fromindex; i < toindex; i++)  
    33.             {  
    34.                 listret.Add(array[i]);  
    35.             }  
    36.             return listret;  
    37.         }  
  • 相关阅读:
    经典布局 ---- 双飞翼
    细嚼浏览器兼容----条件注释判断浏览器版本
    webqq的注册登记和聊天页面--运用jsonp跨域
    Bootstrap框架的要点--栅格系统
    html5橡皮檫特效
    PHP正确获取客户端IP地址
    常用排序算法及Java实现
    Math类中的floor、ceil和round方法
    Java中的动态反射机制和动态代理
    测试
  • 原文地址:https://www.cnblogs.com/dinggf/p/10998908.html
Copyright © 2011-2022 走看看