当前位置:网站首页>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是隐形的,在这个数据环境下,你的代码没有问题,但换一个数据环境,就会出问题,以后开发时,尽量多想一哈如果当前的数据量变大,会不会出现什么问题,如何去规避这个问题;最后希望我的这篇文章能给你带来帮助。
边栏推荐
- Porting RT thread to s5p4418 (II): dynamic memory management
- 明天!“移动云杯”大赛空宣会开播!
- SOC project AHB_ SD_ Host controller design
- leetcode:98. Validate binary search tree
- 【模糊神经网络】基于模糊神经网络的移动机器人路径规划
- Jingwei Hengrun won the 10ppm quality award of paccar group again
- [mask RCNN] target detection and recognition based on mask RCNN
- 2021-07-02
- ROS system problem: rosdep init
- MySQL Optimization: from more than ten seconds to 300 milliseconds
猜你喜欢
随机推荐
Basic fragmentary thoughts
元宇宙由哪些底层技术支撑?
Four great happenings on earth
【Hot100】11. 盛最多水的容器
Class template case - encapsulation of array classes
Qstring to const char*
[mask RCNN] target detection and recognition based on mask RCNN
【Mask-RCNN】基于Mask-RCNN的目标检测和识别
app闪退
2022年6月29日--使用C#迈出第一步--使用 C# 中的“if”、“else”和“else if”语句向代码添加决策逻辑
Several C language implementations
Write about your feelings about love and express your emotions
Solr search
编写并运行第一个Go语言程序
15 minutes learn to use JWT
RT thread migration to s5p4418 (III): static memory pool management
随机网络,无标度网络,小世界网络以及NS小世界的性能对比matlab仿真
Qdebug small details
Linux server installation redis
Steps for formulating class or file templates in idea




![[docsify basic use]](/img/9d/db689f5f13708f3e241474afeca1d0.png)


![[mask RCNN] target detection and recognition based on mask RCNN](/img/80/f3db990b4f242609679d872b0dfe00.png)

