今天发现查询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. 三十分钟理解:双调排序Bitonic Sort,适合并行计算的排序算法

    欢迎转载,转载请注明:本文出自Bin的专栏blog.csdn.net/xbinworld 技术交流QQ群:433250724,欢迎对算法.技术.应用感兴趣的同学加入 双调排序是data-indepen ...

  2. 斯特灵(Stirling)数

    http://zh.wikipedia.org/wiki/%E6%96%AF%E7%89%B9%E7%81%B5%E6%95%B0 第一类:n个元素分成k个非空循环排列(环)的方法总数 递推式:s(n ...

  3. Codeforces 606-C:Sorting Railway Cars(LIS)

    C. Sorting Railway Cars time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  4. SQL相关简单游标

    BEGIN TRY Create Table #Temp_Table_Record_Stat ( .... ) DECLARE table_Cursor CURSOR FOR SELECT objec ...

  5. 简单桶排序算法-python实现

    #-*- coding: UTF-8 -*- import numpy as np def BucketSort(a, n): barrel = np.zeros((1, n), dtype = 'i ...

  6. 写给C#程序员的javascript说明: 各类型变量和prototype

    在javascript中存在类似的私有变量 公有变量和静态变量 私有: var AA=function(){ var aa="im private"; }; 私有变量通过闭包访问. ...

  7. redis3.0自带集群配置

    参考 http://redis.readthedocs.org/en/latest/topic/cluster-tutorial.html http://yindashan.github.io/blo ...

  8. java之mapstruct的应用

    一.MapStruct是一个代码生成器,简化了不同的Java Bean之间映射的处理,所以映射指的就是从一个实体变化成一个实体.例如我们在实际开发中,DAO层的实体和一些数据传输对象(DTO),大部分 ...

  9. jsp的session完成登陆功能

    login.jsp: <%@ page language="java" import="java.util.*" contentType="te ...

  10. django rest_framework 框架的使用03

    rest_framework的 数据解析器 首先需要知道前端发给后端的数据格式头有哪些: media_type = 'application/json' media_type = 'applicati ...