当前位置:网站首页>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是隐形的,在这个数据环境下,你的代码没有问题,但换一个数据环境,就会出问题,以后开发时,尽量多想一哈如果当前的数据量变大,会不会出现什么问题,如何去规避这个问题;最后希望我的这篇文章能给你带来帮助。
边栏推荐
- 0 basic job transfer software test, how to achieve a monthly salary of 9.5k+
- 成品升级程序
- 记录一次腾讯测试开发工程师自动化接口测试实践经验
- Mysql5.7 compressed version installation tutorial
- Go installation and configuration (1)
- [fuzzy neural network] mobile robot path planning based on Fuzzy Neural Network
- 原理:WebMvcConfigurer 与 WebMvcConfigurationSupport避坑指南
- 2021-07-02
- The solution of memcpy memory overlap
- 编写并运行第一个Go语言程序
猜你喜欢

tomorrow! "Mobile cloud Cup" competition air publicity will start!

Why does ETL often become ELT or even let?

Huawei full-scale Daniel shared the 598 page full-color Manual of network protocols for the first time

史上最全一句话木马

Rising posture series: fancy debugging information

leetcode:98. 验证二叉搜索树

【最全】linux服务器上安装Mysql

RT thread Kernel Implementation (I): threads and scheduling

相关数据库问题提问。

C language: exercise 3
随机推荐
Redis cache
[docsify basic use]
Imxq Freescale yocto project compilation record
Linux server installation redis
SOC项目AHB_SD_HOST控制器设计
[datawhale team learning] task02: mathematical operation, string and text, list
Go installation and configuration (1)
Class template case - encapsulation of array classes
Servlet principle
相关数据库问题提问。
Go常用命令
GO安装以及配置(1)
Authority management system
[mask RCNN] target detection and recognition based on mask RCNN
memcpy内存重叠的解决
Base64 encoding method implemented by native JS
[transfer] analysis of memory structure, cache and DMA architecture
Why does ETL often become ELT or even let?
Records of problems solved (continuously updated)
Egret P2 pit encountered by physical engine (1)