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 -> Update Cascade

Update Cascade

From: Vincent Romano <Vinnie123_at_worldnet.att.net>
Date: Wed, 8 Dec 1999 13:27:39 -0500
Message-ID: <82mcg4$k4i$1@bgtnsc02.worldnet.att.net>


I saw the following routine in the Oracle 8 Server Online Documentation to implement an update cascade in Oracle. I have include the routine below. I am confused about the section of code in the "IF Updating" section, because I do not understand why it is necessary to use the update_id field. I cannot understand how the child record could have already been updated. Any help would be appreciated.Here is the routine:



UPDATE Cascade Trigger for Parent Table The following trigger ensures that if a department number is updated in the DEPT table, this change is propagated to dependent foreign keys in the EMP table: CREATE PACKAGE integritypackage AS

   updateseq NUMBER;
END integritypackage;

CREATE or replace PACKAGE BODY integritypackage AS END integritypackage;
ALTER TABLE emp ADD update_id NUMBER; -- create flag col.

CREATE TRIGGER dept_cascade1 BEFORE UPDATE OF deptno ON dept DECLARE
   dummy NUMBER;

CREATE TRIGGER dept_cascade2 AFTER DELETE OR UPDATE

   OF deptno ON dept FOR EACH ROW



Note:

Because this trigger updates the EMP table, the EMP_DEPT_CHECK trigger, if enabled, is also fired. The resulting mutating table error is trapped by the EMP_DEPT_CHECK trigger. You should carefully test any triggers that require error trapping to succeed to ensure that they will always work properly in your environment. Received on Wed Dec 08 1999 - 12:27:39 CST

Original text of this message

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