sql in条件 超过1000字符的处理方法
- private string getOracleSQLIn(string[] ids, string field)
- {
- int count = Math.Min(ids.Length, 1000);
- int len = ids.Length;
- int size = len % count;
- if (size == 0)
- {
- size = len / count;
- }
- else
- {
- size = (len / count) + 1;
- }
- StringBuilder builder = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int fromIndex = i * count;
- int toIndex = Math.Min(fromIndex + count, len);
- string productId = string.Join("','", getArrayValues(fromIndex, toIndex, ids).ToArray());
- if (i != 0)
- {
- builder.Append(" or ");
- }
- builder.Append(field).Append(" in ('").Append(productId).Append("')");
- }
- return " ("+builder.ToString()+") ";
- }
- public List<string> getArrayValues(int fromindex, int toindex, string[] array)
- {
- List<string> listret = new List<string>();
- for (int i = fromindex; i < toindex; i++)
- {
- listret.Add(array[i]);
- }
- return listret;
- }
sql in条件 超过1000字符的处理方法的更多相关文章
- sql语句in超过1000时的写法
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 处理 Oracle SQL in 超过1000 的解决方案
处理oracle sql 语句in子句中(where id in (1, 2, ..., 1000, 1001)),如果子句中超过1000项就会报错.这主要是oracle考虑性能问题做的限制.如果要解 ...
- Oracle SQL in 超过1000 的解决方案
处理 Oracle SQL in 超过1000 的解决方案 处理oracle sql 语句in子句中(where id in (1, 2, ..., 1000, 1001)),如果子句中超过1000项 ...
- 【转】SQL多条件模糊查询解决方案-存储过程
前言: 算法的基本特性在前几篇博客中已经做了详细的说明,经过不断的改进优化,到归仓的时候了,也就是说,该算法告一段落,不再更新. 作为最终的解决方案,简要的总结一下算法特性,以方便读者参阅. l ...
- oracle select in超过1000条报错解决方法
本博客介绍oracle select in超过1000条数据的解决方法,java框架是采用mybatis的,这可以说是一种比较常见的错误:select * from A where id in(... ...
- Mybatis中动态SQL多条件查询
Mybatis中动态SQL多条件查询 mybatis中用于实现动态SQL的元素有: if:用if实现条件的选择,用于定义where的字句的条件. choose(when otherwise)相当于Ja ...
- IN中超过1000处理
后台 所有用到IN的方法,都要考虑超过1000的可能 if(cameraIds != null && cameraIds.length > 0){sql.append(" ...
- oracle中的in参数超过1000的解决方案
在oracle中,使用in方法查询记录的时候,如果in后面的参数个数超过1000个,那么会发生错误,JDBC会抛出"java.sql.SQLException: ORA-01795: 列表中 ...
- FP 某段SQL语句执行时间超过1个小时,并报错:ORA-01652: 无法通过 128 (在表空间 TEMPSTG 中) 扩展
一.出现如下两个错误:1.某一段SQL语句执行时间超过1个小时:2.一个小时后,提示如下错误:ORA-01652: 无法通过 128 (在表空间 TEMPSTG 中) 扩展 temp 段ORA-065 ...
随机推荐
- POJ - 2112 Optimal Milking (dijkstra + 二分 + 最大流Dinic)
(点击此处查看原题) 题目分析 题意:在一个农场中有k台挤奶器和c只奶牛,每个挤奶器最多只能为m只奶牛挤奶,每个挤奶器和奶牛都视为一个点,将编号1~k记为挤奶器的位置,编号k+1~k+c记为奶牛的位置 ...
- Python3学习笔记-更新中
1.Python概况 2.Anaconda安装及使用 3.Pycharm安装及使用 4.Hello World!!! 5.数据类型及类型转换 6.分支结构 7.循环语句 8.异常
- C++练习 | 铁轨问题
#include <iostream> #include <cmath> #include <cstring> #include <string> #i ...
- Python 条件判断 和循环
使用条件判断 if else # 条件派单 if else print('条件派单 if else') # s = input('请输入生日年号:') # birth = int(s) birth = ...
- 我的python学习之旅——安装python
windows下载安装: 1.下载安装包: 访问官方网站:https://www.python.org/downloads/ 下载自己想要的版本安装,这里下载当前最新版3.8: 选择64位的Windo ...
- 首探:Ruby on Rails 简单了解
一. 安装 Ruby安装:https://ruby-china.org/wiki/rvm-guide 注:安装了RVM和Gem后 安装rails: gem install rails -v 5.1.4 ...
- mysql连接数据库时报2003错误怎么解决
mysql 2003是连接错误,连不上服务器. 你目前可以如下方法:进入控制面板->服务管理(我的是管理工具),->服务,然后找到Mysql服务,右键修改属性,改为自启动,以后再重启就没有 ...
- react生态常用库分类
一. web项目 1.脚手架 create-react-app 自动安装react.react-dom 2.核心 react.react-dom 3.路由 react-router.react-rou ...
- java虚拟机精讲
2.程序计数器 是指当前线程所执行字节码的行号指示器 比如if 循环 抛异常 等都需要程序计数器 如果线程执行java方法 程序计数器记录的是虚拟机字节码指令的地址 如果线程执行native方法时程序 ...
- 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 ...