DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: trigger - DELETE Cascade Trigger for Parent Table not working

  1. #1
    Join Date
    Apr 2003
    Posts
    29

    trigger - DELETE Cascade Trigger for Parent Table not working

    CREATE OR REPLACE TRIGGER Dept_del_cascade
    AFTER DELETE ON Dept
    FOR EACH ROW
    BEGIN
    DELETE FROM Emp
    WHERE Emp.Deptno = ld.Deptno;
    END;
    /

    SQL> delete from dept where deptno = 40;
    delete from dept where deptno = 40
    *
    ERROR at line 1:
    ORA-02292: integrity constraint (SCOTT.FK_DEPTNO) violated - child record found


    why does'nt the trigger take care of this problem?

  2. #2
    Join Date
    Aug 2002
    Posts
    115
    try givin before delete!

  3. #3
    Join Date
    Apr 2003
    Posts
    29
    before gives a mutating table error

  4. #4
    Join Date
    Apr 2003
    Location
    South Carolina
    Posts
    148
    Since it's an after trigger, the RI constraint is evaluated first...
    Why don't you have the foreign key as a cascading delete instead of
    trying to put this in a trigger ???

    Gregg

  5. #5
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Originally posted by varshanswamy
    before gives a mutating table error
    No, it doesn't. It can't. It won't.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width