sql - ORACLE TRIGGER update table if another one is updated -


i want change field in rows of table when updating one.
have game table, referee table (with nation_id) , nation table.

want auto update referee_nation_name game table if update nation_id in referee table.
my problem have no idea how referee_id (which unique) when update nation_id in table. if select referee_id :new.nation_id other referee ids peoples life in country... here non working trigger:

create or replace trigger name after update of nation_id on referee each row declare     nationname varchar2(150); begin     select n.name nationname             nation n, referee r, game g       n.nation_id = r.nation_id , g.referee_id = :old.referee_id);     update game set referee_nation_name = nationname referee_id = :old.referee_id; end; 

knowing never design data model stored denormalized data precisely because incredibly hard keep in sync, instructor looking like

create or replace trigger name   before update of nation_id on referee   each row declare     l_nationname varchar2(150); begin     select name       l_nationname        nation      nation_id = :new.nation_id;      update game        set referee_nation_name = l_nationname      referee_id = :new.referee_id; end; 

of course, doesn't address happens when updates nation table change name among other possible holes.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -