今天发现查询Oracle用In查询In的元素不可以超过1000个还需要分成多个1000查询记录博客备忘!!

Load Test的时候发现这么如下这个错误....

ORA-01795: maximum number of expressions in a list is 1000

导致这个问题的原因是因为SQL语句中用到了IN字句,结果IN中的元素个数超过了1000导致了这个错误。如下所示...

declare 
l_cnt pls_integer;
l_list varchar2(32767);
begin
select listagg(level, ',') WITHIN group(order by level)
into l_list
from dual connect by level<=1000; execute immediate 'select count(*) from user_objects where object_id in (' || l_list || ')'
into l_cnt;
end;
/

这个例子中in中元素个数是1000, 可以正常运行,但是下面这个例子就会报错,因为IN中的元素个数超过了1000...

declare 
l_cnt pls_integer;
l_list varchar2(32767);
begin
select listagg(level, ',') WITHIN group(order by level)
into l_list
from dual connect by level<=1001; execute immediate 'select count(*) from user_objects where object_id in (' || l_list || ')'
into l_cnt;
end;
/

解决这个问题的方法是在程序中将一个IN改成多个IN, 或者把IN List 改成一个SELECT语句,把IN List中的元素放到一个Nested Table中。

ORA-01795: maximum number of expressions in a list is 1000的更多相关文章

  1. 错误:maximum number of expressions in a list is 1000

    某一日发现这么如下这么一个错误  --> maximum number of expressions in a list is 1000 原因:因为SQL语句中用到了IN字句,而IN中的元素个数 ...

  2. iOS---The maximum number of apps for free development profiles has been reached.

    真机调试免费App ID出现的问题The maximum number of apps for free development profiles has been reached.免费应用程序调试最 ...

  3. [LeetCode] Third Maximum Number 第三大的数

    Given a non-empty array of integers, return the third maximum number in this array. If it does not e ...

  4. [LeetCode] Create Maximum Number 创建最大数

    Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum numb ...

  5. LeetCode 414 Third Maximum Number

    Problem: Given a non-empty array of integers, return the third maximum number in this array. If it d ...

  6. Failed to connect to database. Maximum number of conections to instance exceeded

    我们大体都知道ArcSDE的连接数有 48 的限制,很多人也知道这个参数可以修改,并且每种操作系统能支持的最大连接数是不同的. 如果应用报错:超出系统最大连接数 该如何处理? 两种解决办法: 第一,首 ...

  7. POJ2699 The Maximum Number of Strong Kings

    Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2102   Accepted: 975 Description A tour ...

  8. [LintCode] Create Maximum Number 创建最大数

    Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum numb ...

  9. tomcat 大并发报错 Maximum number of threads (200) created for connector with address null and port 8080

    1.INFO: Maximum number of threads (200) created for connector with address null and port 8091 说明:最大线 ...

随机推荐

  1. 6款实用的硬盘、SSD固态硬盘、U盘、储存卡磁盘性能测试工具

    一.检测工具名称汇总 HDTune ATTO Disk Benchmark CrystalDiskMark AS SSD Benchmark Parkdale CrystalDiskInfo 二.各项 ...

  2. Laravel学习之旅(一)

    路由 1.简介:简单的说就是将用户的请求转发给相应的程序进行处理: 2.作用:就是建立url和程序之间的映射. 3.请求类型:get.post.put.patch.delete 相比于thinkphp ...

  3. 解决 The word is not correctly spelled问题

    The word is not correctly spelled 此问题是eclipse校验单词拼写造成,如果出在配置文件中,一般会影响到程序的正常执行 解决方法:Window--Preferenc ...

  4. python下的select模块使用 以及epoll与select、poll的区别

    python下的select模块使用 以及epoll与select.poll的区别 先说epoll与select.poll的区别(总结) 整理http://www.zhihu.com/question ...

  5. System.IO.Path类

    System.IO.Path为路径的操作封装了很多很有的东西,利用该类提供的方法能够快速处理路径操作的问题.下面详细了解一下. 1.属性 属性太复杂了,反映什么系统平台的信息,看不懂,等以后看得懂了再 ...

  6. equals方法和==的区别

    equals方法和==的区别   首先大家知道,String既可以作为一个对象来使用,又可以作为一个基本类型来使用.这里指的作为一个基本类型来使用只是指使用方法上的,比如String s = &quo ...

  7. 黑马程序员【JSP九大内置对象和四个作用域】转载

    http://www.cnblogs.com/fanfu1/p/4530980.html JSP九大内置对象和四个作用域 ------- android培训.java培训.期待与您交流! ------ ...

  8. 【monkey】mokey常用命令<一>

    monkey测试的相关的原理 monkey测试的原理就是利用socket通讯的方式来模拟用户的按键输入,触摸屏输入,手势输入等,看设备多长时间会出异常.当Monkey程序在模拟器或设备运行的时候,如果 ...

  9. Bootstrap-CL:Well

    ylbtech-Bootstrap-CL:Well 1.返回顶部 1. Bootstrap Well Well 是一种会引起内容凹陷显示或插图效果的容器 <div>.为了创建 Well,只 ...

  10. [转][ASP.NET]ASP.NET 预编译网站

    [转自]https://msdn.microsoft.com/zh-cn/library/ms227430(v=vs.80).aspx C:\Windows\Microsoft.NET\Framewo ...