sql in条件 超过1000字符的处理方法
2024-09-04 02:37:32
- 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;
- }
最新文章
- lua中的string类型
- [转]在WPF中区别TextBlock和Label
- Oracle PL/SQL块
- Java 集合系列10之 HashMap详细介绍(源码解析)和使用示例
- wp8 入门到精通 高仿微信发信息 键盘不消失
- android源码解析(十七)-->;Activity布局加载流程
- 使用CSS3美化复选框checkbox
- POJ1840 hash
- 百度,google的地理编码
- BZOJ4554 - [TJOI2016&HEOI2016]游戏
- 人工智能之基于face_recognition的人脸检测与识别
- react-native项目中禁止截屏与录屏
- redis命令String类型(四)
- Springboot+ActiveMQ(ActiveMQ消息持久化,保证JMS的可靠性,消费者幂等性)
- Ubuntu18.04 搭建zookeeper单机版集群
- python网络编程:socket、服务端、客户端
- springboot 中事件监听模型的一种实现
- CentOS上部署JAVA服务【转】
- java.sql.SQLException: ORA-00932: 数据类型不一致: 应为 -, 但却获得 CLOB
- ZooKeeper客户端原生API的使用以及ZkClient第三方API的使用