Home » SQL & PL/SQL » SQL & PL/SQL » How do I find child tables and manipulate their content?
How do I find child tables and manipulate their content? [message #21797] Fri, 30 August 2002 13:00 Go to next message
Fredrik Ohrn
Messages: 2
Registered: August 2002
Junior Member
Hello!

I have a bunch of parent tables and an even bigger bunch of child tables all tangled in a complicated referential relationship mess.

I have two things I want to do:

1. "Reparent" child records.
Find all child tables and update their records to point to a new parent record B instead of the old parent record A.

Input is an arbitary table and the two parent records.

2. Cascade delete child records.
Find all child tables and delete all records referring to parent record A.

Input is an arbitary table and the parent record A.

(I don't think on cascade delete will work, since I don't want to delete the parent record itself. Or?)

I assume a PL/SQL script will be necessary to accomplish this. I would gladly RTFM but I s**k so bad at PL/SQL so I don't even know where to start.

Suggestions, examples and pointers to more reading would be greatly appreciated.

Regards,
Fredrik
Re: How do I find child tables and manipulate their content? [message #21799 is a reply to message #21797] Fri, 30 August 2002 13:33 Go to previous message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
[code]Hi,
cascading delete is supported in oracle ( eventhough, oracle strongly NOT RECOMENDS to use it).
add
'on delete cascade'
in every child table.

if you are looking for cascading updates, by default
oracle does not support it.
But there are workarounsds.
pls refer to our other posting.
[code]<a href = http://www.orafaq.net/cgi-bin/msgboard/view.cgi?board=plsql&message=8584&query=cascade%20updates> implementing cascading updates [/url]
ust copy , create and execute the complete code over there..
this procedure is generic...i.e...you can use this against any table  in the datbase.

Previous Topic: Re: minus operator
Next Topic: urgent
Goto Forum:
  


Current Time: Fri Apr 19 12:55:13 CDT 2024