Home » SQL & PL/SQL » SQL & PL/SQL » How to get all child records from a table with multiple self referential integrity constraints? (merged 3) (11g)
How to get all child records from a table with multiple self referential integrity constraints? (merged 3) [message #676251] Thu, 23 May 2019 02:01 Go to previous message
rrcr
Messages: 18
Registered: January 2019
Junior Member
As per the requirement i have to identified data from table t1. Once the data is identified i need to identify its child records as well.
I could easily identify its childs if there is only one self referential constraint.
like

select * from t1
start with c1=100
connect by prior c1=c2;

But My table has multiple self referential integrity constraints like below


create table t1(
c1 number pk,
c2 number references c1,
c3 number references c1,
c4 number references c1);


i have tried to identify the childs of each self RI separately. But the problem here is after identifying the childs i have to delete all the childs and parent records.
With the approach of identifying the self referential Integrity separately we may find one record is child in one self RI the same record might be parent in other Self RI. so while deleting we are facing child record found issue.

so i have used the below query to identify all the childs in one shot. But the query is running for hours and not getting finished.


select * from t1
start with c1=100
connect by prior c1=c2 or prior c1=c3 or prior c1=c4;


Please suggest a way to identify all the childs and delete them without constraint issues.

Thanks
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: case if avec PL/SQL
Next Topic: can we call an sql script from the code of a stored procedure
Goto Forum:
  


Current Time: Thu Apr 25 16:20:36 CDT 2024