从相互关联的表中删除记录的过程

procedure for delete records from tables Related to each other

我的 table 有这些结构(在 Oracle 中):

---table grandmother ---
  ID
  some other columns


---table mother---
  ID
  grandmother_ID
  some other columns

---table girl
  ID
  mother_ID
  some other columns

---table grandchild1
  ID
  girl_ID
  some other columns 

---table grandchild2
  ID
  girl_ID
  some other columns 

现在,我如何编写一个程序来删除祖母的一条记录table?很明显,我们应该删除母亲 table 的 grandmother_IDs 和女孩 table 的 mother_IDs 以及孙子 1 和孙子 2 的 girl_IDs 的记录。

create or replace PROCEDURE GRAND_MOTHER_DELETE
( 
    IN_ID      IN      GRAND_MOTHER.ID%TYPE 
 )
 AS 
 BEGIN

  DELETE FROM GRAND_CHILD1 GC1 , GRAND_CHILD2 GC2 USING GC1 , GC2
  WHERE GC1.GIRL_ID = GC2.GIRL_ID
  AND GC2.GIRL_ID IN(   
  SELECT ID FROM GIRL WHERE MOTHER_ID IN (
  SELECT ID FROM MOTHER WHERE GRAND_MOTHER_ID=IN_ID));      

  DELETE
  FROM   GRAND_MOTHER
  WHERE  ID  = IN_ID; 

 END;

但是它给出了语法错误。

根据@Littlefoot 的回答,我在 grandchild1、grandchild2、girl 和 mother 表中添加 ON DELETE CASCADE,我的问题就解决了。