Using CONNECT BY with DBA_CONSTRAINTS VIEW
641067Jun 6 2008 — edited Jun 6 2008I am building a query using the Dba_Constraints view and CONNECT BY Operator.
I should fill some tables and I want to avoid FKs errors, but... I'll need to follow the right order to do that. So, I wrote a query but it's not working!. The first version stopped the recursion on the second level... I tried to fix it but I've only got an even worst result!
This is the 1st version:
SELECT SYS_CONNECT_BY_PATH(C.TABLE_name, ' >> ') "Path"
FROM dba_constraints c
WHERE owner = :anOwner
AND LEVEL > 1 CONNECT BY constraint_name = prior r_constraint_name
AND PRIOR owner = prior r_owner
ORDER BY LEVEL DESC,
TABLE_NAME ASC;
Can anyone help me with this query?
Thanks!
Martin