So I have this particular attribute (Sportcode
) I am asked to implement update cascade by writing a trigger. this particular attribute is in the table below:
Sports
Sportcode sport name sport event no
--------------- ------------------------------ ---------------
AR Archery 2
AT Athletics 3
BD Badminton 4
BK Basketball 6
BS Baseball 5
BV Beach Volleyball 26
How do I use a trigger to implement update cascade for Sportcode
?
EDIT:
I'm not sure whether this is what i am supposed to do but i came up with something like this:
CREATE OR REPLACE TRIGGER Sportcode_Upd_Cas
BEFORE UPDATE OF Sportcode ON sports
FOR EACH ROW
BEGIN
UPDATE sports
SET Sportcode =:new.Sportcode
WHERE Sportcode =:old.Sportcode;
DBMS_OUTPUT.PUT_LINE('Corresponding Sportcode in the Sports table has also been updated');
END;