当前位置:网站首页>oracle数据库报列表中最大表达式为1000错误
oracle数据库报列表中最大表达式为1000错误
2022-06-30 06:57:00 【薄荷味脑花】
oracle数据库报列表中最大表达式为1000错误
1.解释:
这个错误是指sql中in中的参数最多不能超过1000个,这是oracle数据库这样设定的。
2.背景复现:
当在正式环境开发中,由于数据量会特别大,会遇到in()括号中的参数达到超过1000个的情况,这样的情况下,就会复现报错,其截图如下:
3.解决思路:
通过上述可以发现,只要in的参数保证在1000以内,那么就不会出现这个报错。所以,我们解决这个问题的核心思路就是解决避免in的参数超过1000。
4.解决方案:
我的解决方案有两种:
1.如果使用的是后台sql拼接方式:可以在in的时候,再写个if判断,当要In的参数index数值取999的模为0,就再in(放后边的数据)
2.如果使用的是xml文件写sql,用到sql动态标签,思路和方案一一样,我这里距展示方案二的代码写法:
select name,sex,age from man where id in
<foreach collection="idList" index="index" open="(" close=")" separator="," item="id">
<!--防止数据超过1000报错-->
<if test="(index % 999) == 998">
0 )
or id in (
</if>
#{id}
</foreach>
最后的大概样子是这样的:
select name,sex,age from man where id in (1,2,3) or id in (4,5,6) or id in (7,8,9)...
5.结语:
通过这个报错,我们会发现,有的bug是隐形的,在这个数据环境下,你的代码没有问题,但换一个数据环境,就会出问题,以后开发时,尽量多想一哈如果当前的数据量变大,会不会出现什么问题,如何去规避这个问题;最后希望我的这篇文章能给你带来帮助。
边栏推荐
- 2022年6月29日--使用C#迈出第一步--使用 C# 中的“if”、“else”和“else if”语句向代码添加决策逻辑
- freemarker
- 【Mask-RCNN】基于Mask-RCNN的目标检测和识别
- The solution of memcpy memory overlap
- How to set the hot deployment of idea web project
- Installation du serveur linux redis
- RT thread Kernel Implementation (V): timer
- Deep learning --- the weight of the three good students' scores (3)
- Cluster distributed
- 【Hot100】11. Container with the most water
猜你喜欢

Numpy中的四个小技巧
![[docsify basic use]](/img/9d/db689f5f13708f3e241474afeca1d0.png)
[docsify basic use]

RT thread Kernel Implementation (II): critical area, object container

6、 Shopping ⻋ and orders

Steps for formulating class or file templates in idea

Deploying web projects using idea

Class template case - encapsulation of array classes

SOC_AHB_SD_IF

How does the CPU recognize the code?

Record one time of Tencent Test Development Engineer's automation interface test practice experience
随机推荐
Notes: environment variables
【Mask-RCNN】基于Mask-RCNN的目标检测和识别
Authority management system
15 minutes learn to use JWT
Four tips in numpy
相关数据库问题提问。
leetcode:98. Validate binary search tree
[JSON tutorial] Chapter 1 learning notes
RT thread Kernel Implementation (I): threads and scheduling
RT thread Kernel Implementation (II): critical area, object container
Out of class implementation of member function of class template
What if I forget my account number after opening an account? Is it safe to open an account online?
Fastapi learning Day1
CPU到底是怎么识别代码的?
1285_把AUTOSAR函数以及变量等定义的宏用脚本展开以提高可读性
Fastapi learning Day2
Determine whether the picture is in JPG picture format
明天!“移动云杯”大赛空宣会开播!
Which securities company is good for opening a mobile account? Also, is it safe to open an account online?
Egret P2 physical engine (1) small ball falling demo