feedburner
Enter your email address:

Delivered by FeedBurner

feedburner count

Changing Data in Constraining table

Labels:

Constraining Table:
A constraining table is a table that the triggering event might need to read, either directly for a SQL statement or indirectly for a declarative referential integrity constraint.
NOTE: Tables are not considered constraining for STATEMENT triggers.

Example:
Try changing data in a constraining table.

When the value of DEPTNO changes in the DEPT parent table, trying to cascade the update to the corresponding rows in the EMP child table produces runtime error.

CREATE OR REPLACE TRIGGER cascade_updates
AFTER UPDATE OF deptno
ON dept
FOR EACH ROW
BEGIN
UPDATE emp
SET emp.deptno = :new.deptno
WHERE emp.deptno = :old.deptno;
END;

Now let’s try it.

UPDATE dept
SET deptno = 1
WHERE deptno = 20;

ORA-04091: table name is mutating, trigger/function may not see it.

In the above example, cascade_updates trigger tries to change the data in the constraining table, which is not allowed.



0 comments:

Post a Comment