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. public List<string> getArrayValues(int fromindex, int toindex, string[] array)
  29. {
  30. List<string> listret = new List<string>();
  31. for (int i = fromindex; i < toindex; i++)
  32. {
  33. listret.Add(array[i]);
  34. }
  35. return listret;
  36. }

sql in条件 超过1000字符的处理方法的更多相关文章

  1. sql语句in超过1000时的写法

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  2. 处理 Oracle SQL in 超过1000 的解决方案

    处理oracle sql 语句in子句中(where id in (1, 2, ..., 1000, 1001)),如果子句中超过1000项就会报错.这主要是oracle考虑性能问题做的限制.如果要解 ...

  3. Oracle SQL in 超过1000 的解决方案

    处理 Oracle SQL in 超过1000 的解决方案 处理oracle sql 语句in子句中(where id in (1, 2, ..., 1000, 1001)),如果子句中超过1000项 ...

  4. 【转】SQL多条件模糊查询解决方案-存储过程

    前言:   算法的基本特性在前几篇博客中已经做了详细的说明,经过不断的改进优化,到归仓的时候了,也就是说,该算法告一段落,不再更新. 作为最终的解决方案,简要的总结一下算法特性,以方便读者参阅. l ...

  5. oracle select in超过1000条报错解决方法

    本博客介绍oracle select in超过1000条数据的解决方法,java框架是采用mybatis的,这可以说是一种比较常见的错误:select * from A where id in(... ...

  6. Mybatis中动态SQL多条件查询

    Mybatis中动态SQL多条件查询 mybatis中用于实现动态SQL的元素有: if:用if实现条件的选择,用于定义where的字句的条件. choose(when otherwise)相当于Ja ...

  7. IN中超过1000处理

    后台 所有用到IN的方法,都要考虑超过1000的可能 if(cameraIds != null && cameraIds.length > 0){sql.append(" ...

  8. oracle中的in参数超过1000的解决方案

    在oracle中,使用in方法查询记录的时候,如果in后面的参数个数超过1000个,那么会发生错误,JDBC会抛出"java.sql.SQLException: ORA-01795: 列表中 ...

  9. FP 某段SQL语句执行时间超过1个小时,并报错:ORA-01652: 无法通过 128 (在表空间 TEMPSTG 中) 扩展

    一.出现如下两个错误:1.某一段SQL语句执行时间超过1个小时:2.一个小时后,提示如下错误:ORA-01652: 无法通过 128 (在表空间 TEMPSTG 中) 扩展 temp 段ORA-065 ...

随机推荐

  1. POJ - 2112 Optimal Milking (dijkstra + 二分 + 最大流Dinic)

    (点击此处查看原题) 题目分析 题意:在一个农场中有k台挤奶器和c只奶牛,每个挤奶器最多只能为m只奶牛挤奶,每个挤奶器和奶牛都视为一个点,将编号1~k记为挤奶器的位置,编号k+1~k+c记为奶牛的位置 ...

  2. Python3学习笔记-更新中

    1.Python概况 2.Anaconda安装及使用 3.Pycharm安装及使用 4.Hello World!!! 5.数据类型及类型转换 6.分支结构 7.循环语句 8.异常

  3. C++练习 | 铁轨问题

    #include <iostream> #include <cmath> #include <cstring> #include <string> #i ...

  4. Python 条件判断 和循环

    使用条件判断 if else # 条件派单 if else print('条件派单 if else') # s = input('请输入生日年号:') # birth = int(s) birth = ...

  5. 我的python学习之旅——安装python

    windows下载安装: 1.下载安装包: 访问官方网站:https://www.python.org/downloads/ 下载自己想要的版本安装,这里下载当前最新版3.8: 选择64位的Windo ...

  6. 首探:Ruby on Rails 简单了解

    一. 安装 Ruby安装:https://ruby-china.org/wiki/rvm-guide 注:安装了RVM和Gem后 安装rails: gem install rails -v 5.1.4 ...

  7. mysql连接数据库时报2003错误怎么解决

    mysql 2003是连接错误,连不上服务器. 你目前可以如下方法:进入控制面板->服务管理(我的是管理工具),->服务,然后找到Mysql服务,右键修改属性,改为自启动,以后再重启就没有 ...

  8. react生态常用库分类

    一. web项目 1.脚手架 create-react-app 自动安装react.react-dom 2.核心 react.react-dom 3.路由 react-router.react-rou ...

  9. java虚拟机精讲

    2.程序计数器 是指当前线程所执行字节码的行号指示器 比如if 循环 抛异常 等都需要程序计数器 如果线程执行java方法 程序计数器记录的是虚拟机字节码指令的地址 如果线程执行native方法时程序 ...

  10. org.apache.shiro.realm.AuthorizingRealm - No cache or cacheManager properties have been set. Authorization cache cannot be obtained.

    项目中用spring shiro来处理权限的问题,但是启动的时候会打印如下日志 org.apache.shiro.realm.AuthorizingRealm - No cache or cacheM ...