今天发现查询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. Centos 7中的网卡一致性命名规则

    一致性网络设备命名,即Consistent Network Device Naming 一.为什么需要这个 服务器通常有多块网卡,有板载集成的,同时也有插在PCIe插槽的. Linux系统的命名原来是 ...

  2. 基于tiny4412的u-boot移植(一)

    作者信息 作者:彭东林 邮箱:pengdonglin137@163.com QQ: 405728433 平台介绍 开发环境:win7 64位 + VMware11 + Ubuntu14.04 64位 ...

  3. leetcode122 买卖股票的最佳时机 python

    题目:给定一个数组,它表示了一只股票的价格浮动,第i个元素代表的是股票第i天的价格.设计一个函数,计算出该股票的最大收益,注意,可以多次买入卖出,但下一次买入必须是在本次持有股票卖出之后.比如[1,7 ...

  4. [笔记] linux中的计划任务crontab

    不能拒绝进步 cron来源于希腊单词chronos(意为"时间"),指linux系统下一个自动执行指定任务的程序(计划任务). 1--crontab 的命令选项 #crontab ...

  5. CF1061F:Lost Root(交互&概率)

    The graph is called tree if it is connected and has no cycles. Suppose the tree is rooted at some ve ...

  6. 关于SSL的error问题

    今天模拟网页版微信登录的时候又碰到一个SSLError的问题 requests.exceptions.SSLError: [Errno 1] _ssl.c:503: error:14090086:SS ...

  7. flow 编写flow-typed 定义(官方文档)

    此为官方文档,因为墙的问题,记录下来: Before spending the time to write your own libdef, we recommend that you look to ...

  8. std::function与std::bind 函数指针

    function模板类和bind模板函数,使用它们可以实现类似函数指针的功能,但却却比函数指针更加灵活,特别是函数指向类 的非静态成员函数时. std::function可以绑定到全局函数/类静态成员 ...

  9. 【转】Linux下的文本dos格式转Unix格式,去除^M符号

    原文网址:http://blog.csdn.net/kobejayandy/article/details/13291525 问:我在Windows中通过FTP传一个文本文件到Linux中,但是打开文 ...

  10. xmlns和xsi之schemaLocation

    appplicationContex.xml文件报错:元素 "util:constant" 的前缀 "util" 未绑定 在根节点添加了“xmlns:util= ...