I ‘m trying to write CONNECT BY PRIOR on two fields. Any got any idea?
Eventually I want something like following. Unfortunately it seems not working
SELECT *
FROM emp
CONNECT BY PRIOR emp.type = emp.parenttype AND emp.ID = emp.ParentID
Create table script:
CREATE TABLE emp (
ConnectionPkID NVARCHAR2(16) Not Null,
EmpType NVARCHAR2(2) Not Null,
EmpID NVARCHAR2(20) Not Null,
ParentID NVARCHAR2(20) Not Null,
ParentType NVARCHAR2(2) Not Null, );
Given this test data:
this version of your query works:
The important bit is to tag each operand in the CONNECT BY clause with PRIOR.