Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: I need help with a delete trigger

Re: I need help with a delete trigger

From: C. Mason <cmason_at_aai.arco.com>
Date: Tue, 6 Oct 1998 15:43:58 GMT
Message-ID: <F0EwyM.MHK@news.arco.com>


Don't use a trigger. Recreate the foreign key on deptno using the ON DELETE CASCADE clause.
klam80_at_my-dejanews.com wrote in message <6vb750$j8v$1_at_nnrp1.dejanews.com>...
>Hi all,
>
>I have the following problem about triggers.
>For example, dept.deptno is a primary key, and emp.deptno is a foreign key
>referring to dept.deptno.
>I want to automatically delete all corresponding rows in emp when I delete
a
>row from dept. So I wrote:
> create trigger delDept
> before delete on dept
> for each row
> begin
> delete from emp where deptno = :old.deptno;
> end;
>
>When I tried to delete from dept it says table emp is constraining. The
>trigger can't modify it. But the only Fk on emp is the deptno. This was
>supposed to be straightforward. Any idea? Thanks. Please email to
>klam80_at_hotmail.com
>
>Kevin
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
Received on Tue Oct 06 1998 - 10:43:58 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US