ORA-01436: CONNECT BY loop in user data
1、使用 connect by nocycle (不推荐),该方法得不到正确的结果。
2、修改基础数据 。
借用网上有同学的提供的实验:
create table automobiles(
part_id number(5)
constraint pk_auto_part_id primary key,
parent_id number(5)
constraint fk_auto_ppid_ references automobiles(part_id),
part_cname varchar2(30) not null,
part_ename varchar2(30) not null,
mp_cost number(9,2),
desribe varchar2(20)
);
--插入数据
insert into automobiles values( 1,1,'汽车','mobile',84321.99,'Assembly');
insert into automobiles values( 2,1,'车身','bodywork',19892.99,'Manufacture');
insert into automobiles values( 3,1,'发送机','engine',42128,'Purchase');
insert into automobiles values( 4,1,'附件','attached',15212,'Assembly');
insert into automobiles values( 5,2,'保险杠','bumper',4812.95,'Purchase');
insert into automobiles values( 6,2,'底盘','chassis',12795.11,'Manufacture');
insert into automobiles values( 7,2,'行李箱','Boot',812.11,'Manufacture');
insert into automobiles values( 8,6,'车轮','Wheel',2062.2,'Manufacture');
insert into automobiles values( 9,6,'挡泥板','Mudguard',990,'Manufacture');
insert into automobiles values( 10,8,'轮胎','Tyre',300,'Purchase');
insert into automobiles values( 11,3,'发送机盘','Bonnet',3212,'Manufacture');
insert into automobiles values( 12,3,'活塞','Piston',1112.2,'Manufacture');
insert into automobiles values( 13,3,'汽化器','Carburetter',712.29,'Manufacture');
insert into automobiles values( 14,4,'变速器','Gearbox',5712.25,'Manufacture');
insert into automobiles values( 15,4,'仪表板','Dashboard',538.92,'Manufacture');
insert into automobiles values( 16,14,'制动器','Carburetter',712.29,'Manufacture');
insert into automobiles values( 17,14,'变速杆','Gearshift',2001,'Manufacture');
insert into automobiles values( 18,17,'传动轴','Shaft',1101,'Manufacture');
insert into automobiles values( 19,15,'里程表','Milometer',350.28,'Purchase');
/
--分层sql脚本语句练习
select level,part_id,parent_id,part_cname,part_ename,mp_cost,desribe
from automobiles
start with part_id=1
connect by prior part_id=parent_id
order by level;
--缩进显示
select level,
lpad(' ',2*level-1)||part_cname||' '||part_ename as partName
from automobiles
start with part_id=1
connect by prior part_id=parent_id
order by level;
上面两个sql执行的时候都会报ORA-01436: CONNECT BY loop in user data
解决方案入下:
方案1:在connect by 后面加上nocycle ,不循环。得到的结果可能就不是你想要的了。
方案2:把第一条记录的parent_id 置为null ,这样做就不会产生死循环。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15489979/viewspace-742432/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/15489979/viewspace-742432/
ORA-01436: CONNECT BY loop in user data相关推荐
- 数据库异常---ORA-01436: 用户数据中的 CONNECT BY loop in user data 循环
数据库 ORA-01436: 用户数据中的 CONNECT BY loop in user data 循环 技术qq交流群:JavaDream:251572072 教程下载,在线交流:创梦IT社 ...
- PLSQL - 递归子查询RSF打破CONNECT BY LOOP限制
例如有表EMP_ROLES存有数据如下图 RNAME表示员工充当的角色名称,当一人身兼多职时,便会以+号串联各个角色 这是一种很聪明的存储方法,但有时我们却又可能需要拆出每个人的所有角色以便匹配,也就 ...
- oracle中 start with,Oracle中connect by...start with...的使用
大致写法:select * from some_table [where 条件1] connect by [条件2] start with [条件3];其中 connect by 与 start wi ...
- 数据库学习笔记---connect by的简单用法
connect by的简单用法 技术qq交流群:JavaDream:251572072 教程下载,在线交流:创梦IT社区:_______以前的网站现在不弄了,抱歉 ---------------- ...
- Start with - Connect by - level
Code --根目录开始遍历 --向下遍历 select prior a "prior_a" , prior b "prior_b" , prior c ...
- ORA-01436 与 层次查询CONNECT BY
一. ORA-01436报错 开发遇到一个报错 ORA-01436: CONNECT BY loop in user data (ORA-01436: 用户数据中的 CONNECT BY 循环). 1 ...
- oracle 层次查询 connect by
Hierarchical Queries 语法 connect by [nocycle] condition [start with condition] start with condition c ...
- ORA-01436: 用户数据中的 CONNECT BY 循环
SELECT r1.region_id,parent_id FROM cnl_region r1 WHERE r1.region_id =1 ST ...
- java.sql.SQLException: ORA-01436: 用户数据中的 CONNECT BY 循环
SELECT r1.region_id,parent_id FROM cnl_region r1 WHERE r1.region_id =1 START WITH r1.region_id = 1 C ...
最新文章
- 硬肝!超详细matplotlib基础介绍!!!
- 巴菲特+查理芒格+投资理论+经典语录+给韭菜的启示
- extjs4.0的高级组件grid补充01选择模式selection和表格特性feature
- day1学python Hello Python
- php之快速入门学习-17(PHP 命名空间)
- Mysql 索引 总结 —— 概述 || 索引优势劣势|| 索引结构(索引是在MySQL的存储引擎层中实现的)|| BTREE 结构||B+TREE 结构||MySQL中的B+Tree||索引分类
- centos mysql mongodb_Linux 平台安装 MongoDB | 菜鸟教程
- 开始用Flutter做游戏吧
- 区块链的爆发仍为时尚早......
- 《python基础教程(第二版)》学习笔记 基础部分(第1章)
- Openpyxl:读取/写入Excel文件的Python模块
- 干货 | 万字长文带你复习线性代数!
- 融媒体需要什么计算机软件,融媒体时代对编辑的能力要求
- Ubuntu下载QQ
- C语言如何设置随机数
- 下载 | mqtt4aliyun 阿里云 IoT 物联网 设备模拟器 Mac , Windows版本
- java sshd实现连接ssh操作
- SpringMVC + MyBatis + MySQL + Redis(作为二级缓存) 配置
- 我的idea偏好设置
- Postgre 安装提示Installation may not complete correctly.
热门文章
- #6004. 「网络流 24 题」圆桌聚餐(重点整理两种网络流输出方式)
- 出事了,多家“巨头公司”遭受网络攻击,全球数百万用户信息恐遭数据泄露
- ubuntu下使用.deb安装显卡驱动+cuda8.0
- 中国灭火系统市场趋势报告、技术动态创新及市场预测
- kubeedge设备添加以及mapper管理
- 码农应该对自己好一点【挑选水杯全攻略】
- c语言字母倒金字塔编程,C语言倒金字塔编程.ppt
- 投资合伙人股份分配_合伙人股权分配,你必须知道的三大要点!
- 用jsp的mvc模式的新闻发布系统_海鸥模式:创新文旅融合 促进消费升级
- IKE与IPSec详解