
---------------------------------------------------
prompt Branches view 'instead-of' triggers
---------------------------------------------------

create or replace trigger sdd_branches_i
 instead of insert on sdd_branches
 for each row
 declare
  branch_id number;
 begin
  branch_id:=jr_version.mk_branch(:new.name,:new.notes);
 end sdd_branches_i;
/

create or replace trigger sdd_branches_u
 instead of update on sdd_branches
 for each row
 declare
 begin
  if :new.name!=:old.name then
   jr_version.change_branch_label(:old.branch_id
                                 ,:new.name);
  end if;
  if :new.notes!=:old.notes then
   jr_version.change_branch_label_notes(:old.branch_id
                                        ,:new.notes);
  end if;
 end sdd_branches_u;
/

create or replace trigger sdd_branches_d
 instead of delete on sdd_branches
 for each row
 declare
 begin
  jr_version.delete_branch(:old.branch_id);
 end sdd_branches_d;
/

