Oracle递归死循环怎么办?
drop table test1 purge;
create table test1(id number, parent_id number,name varchar2(10));
insert into test1 values(1,2,’’);
insert into test1 values(2,1,’’);
insert into test1 values(3,2,’’);
commit;
select * from test1 start with id=1 connect by PRIOR id = parent_id;
ORA-01436: 用戶數(shù)據(jù)中的 CONNECT BY 循環(huán)
查出問題數(shù)據(jù):
SELECT *
FROM test1 u, test1 l
where u.parent_id = l.id
AND l.parent_id = u.id;
ID PARENT_ID NAME ID PARENT_ID NAME
2 1 1 2
1 2 2 1
臨時(shí)的解決方法:使用nocycle還是可以查出數(shù)據(jù)來的,只是不循環(huán)了
select * from test1 start with id=1 connect by nocycle PRIOR id = parent_id;
ID PARENT_ID NAME
1 2
2 1
3 2
永久的解決方法,把數(shù)據(jù)調(diào)整了。
總結(jié)
以上是生活随笔為你收集整理的Oracle递归死循环怎么办?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java button属性设置_java
- 下一篇: css设置全局内边距为0,重置CSS