Oracle CONNECT BY Behavior

It seemed to me that I understand how Oracle works CONNECT BY.

But then I found it.

select dual.*, CONNECT_BY_ISCYCLE from dual
connect by nocycle 1=1
and LEVEL <= 2
;

leads to

DUMMY   CONNECT_BY_ISCYCLE
X       0
X       0

but

select dual.*, CONNECT_BY_ISCYCLE from dual
connect by nocycle 1=1
and LEVEL <= 2
and prior dummy = dummy
;

prints only 1 line

DUMMY   CONNECT_BY_ISCYCLE
X       1

I expected the same result as in the first query.

Can someone explain to me or explain it to me?

This value Oracle Database 12c Release 12.1.0.1.0 - 64bit Production

+4
source share
1 answer

How does Oracle identify "loops" in a hierarchical query?

If this is documented, it is not very good. In any case, I think we found the correct and complete (and, indeed, quite simple) answer in the OTN discussion: https://community.oracle.com/thread/3999985

: , Oracle , PRIOR connect by, , , .

" 5 <= 100", 100 . , "" , PRIOR CONNECT BY, .

, connect by [other conditions here] and prior sys_guid() is not null. sys_guid() null; connect by PRIOR, , ( !), " ", level , "". (- "", , Oracle .)

+3

Source: https://habr.com/ru/post/1678856/


All Articles