The maximum recursion 100 has been exhausted before statement completion
来源:互联网 发布:淘宝网时尚女鞋 编辑:程序博客网 时间:2024/06/06 00:55
在执行带有with 递归的SQL脚本时,出现异常: The statement terminated. The maximum recursion 100 has been exhausted before statement completion
异常解释:递归超出了最大递归次数,即100,也就是说递归调用的层数超过了100。
正常逻辑:既然递归层数100不够,那么我们可以修改最大值,在递归语句后面 添加: option (maxrecursion N)即可。N在 0 到32767 之间的非负整数,当指定0时,不会套用任何限制。如果未指定这个选项,伺服器的预设限制是100。
实际情况:递归套用100层,这是很恐怖的情况,也是几乎不存在的情况,那出现这个问题的是什么呢?只有死循环了。
例如:A是B的父节点,B是C的父节点,C是A的父节点,数据表如下:
IdNameParentId1A32B13C2
现在执行一下脚本,来查询 A的所有子节点
WITH ret AS( SELECT Id FROMData WHEREId = 1 UNION ALL SELECTt.Id FROMData t INNER JOIN ret r ON t.ParentId = r.Id )select distinct Id from ret;
执行脚本时,递归次数超出了100的默认值,便会报错,即便是添加上option (maxrecursion ),也会陷入死循环。
解决方案:避免出现死循环,将现有表里的死循环就纠正过来
0 0
- The maximum recursion 100 has been exhausted before statement completion
- RocketMQ:The producer group has been created before, specify another name please.
- Error: String or binary data would be truncated. The statement has been terminated
- The maximum report processing jobs limit configured by your system administrator has been reached
- The maximum string content length quota (8192) has been exceeded while reading XML data
- 解决sybase备份错误The maximum number of site handlers, 10 has been exceeded
- The maximum string content length quota (8192) has been exceeded while reading XML data
- The maximum number of apps for free development profiles has been reached
- The maximum number of apps for free development profiles has been reached.
- The maximum number of apps for free development profiles has been reached
- The surface has been released
- the surface has been released
- 解决WCF The maximum nametable character count quota (16384) has been exceeded while reading XML data问题
- iOS开发中,提示信息The maximum number of apps for free development profiles has been reached
- ORA-39095: Dump file space has been exhausted: Unable to allocate 8192 bytes
- ORA-39095: Dump file space has been exhausted: Unable to allocate 8192 bytes
- DataPump Export (EXPDP) Error ORA-39095 Dump File Space Has Been Exhausted [ID 559692.1]
- ORA-39095: Dump file space has been exhausted: Unable to allocate 8192 bytes
- Cocoa框架概览
- Isuzu Forward & Isuzu F-Series
- Mac OS在Vmware中如何修改桌面分辨率
- (2)获取网页源代码——Python
- 详解使用Ghost安装Win7系统步骤
- The maximum recursion 100 has been exhausted before statement completion
- 在C#客户端用HTTP上传文件到Java服务器
- ISUZU Giga/EXR/CXZ
- IOS开发基础Object-C( 15)-- block的使用方法
- Android ObjectAnimator ValueAnimation学习
- 如何将ffmpeg在windows编译和使用
- SqlServer中实现返回刚插入记录的ID
- J2EE的常用十三规范——java菜鸟成长记
- P17 (*) Split a list into two parts; the length of the first part is given.