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.         }  
  • 相关阅读:
    ElementUI的Upload上传,配合七牛云储存图片
    Vue : props 使用细节(父组件传递数据给子组件)
    vue弹窗插件实战
    vue实现单选多选反选全选全不选
    Vue.js新手入门指南
    ref 与 $refs 如何关联
    input框只允许输入正整数、正数(包含小数)的解决方法 vue.js实现
    Vue.js 使用 Swiper.js 在 iOS 11 时出现错误
    svn使用规范
    Android 动态设置控件获取焦点
  • 原文地址:https://www.cnblogs.com/dinggf/p/10998908.html
Copyright © 2011-2022 走看看