Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL question
deanbrown3d schrieb am 03.05.2005 in
<1115127879.813395.277140_at_z14g2000cwz.googlegroups.com>:
> Suppose I have a table A that has a field PARENT_SEQ_I that is a FK
> onto the same table field SEQ_I.
> Also, suppose that the parent record in the 'group' has PARENT_SEQ_I
> set to point to its own SEQ_I.
> Can I "delete from A where PARENT_SEQ_I = x"?
> The question is, if the parent record is deleted first, then the FK
> constraints on the other records will throw an error. However, if the
> child records that point to the parent are deleted first, and THEN the
> parent is deleted, all will be ok. So, will it fail sometimes if I let
> oracle randomly choose the order of things to delete?
I'm afraid you are right, O will delete as it comes. But the problems
doesn't stop there.
If a key you want to delete is a primary key for other rows the problem
is the same.
maybe you should write a trigger before delete on ... for each row, in
that you recursively delete all rows that depend on the row you want to
delete.
> Thanks
HTH
> Dean
Andreas
-- wenn email, dann AndreasMosmann <bei> web <punkt> deReceived on Tue May 03 2005 - 09:58:14 CDT
![]() |
![]() |