
---------------------------------------------------
prompt Workareas view 'instead-of' triggers
---------------------------------------------------

create or replace trigger sdd_workareas_i
 instead of insert on sdd_workareas
 for each row
 declare
  workarea_id number;
 begin
  workarea_id:=jr_workarea.create_workarea(:new.owner
                                          ,:new.name
                                          ,:new.description
                                          ,:new.kind);
 end sdd_workareas_i;
/

create or replace trigger sdd_workareas_u
 instead of update on sdd_workareas
 for each row
 declare
 begin
  if :new.name!=:old.name then
   jr_workarea.rename_workarea(:old.irid
                              ,:new.name);
  end if;
  if :new.description!=:old.description then
   jr_workarea.change_workarea_desc(:old.irid
                                   ,:new.description);
  end if;
  if :new.is_compiled!=:old.is_compiled then
   jr_workarea.set_compile_flag(:old.irid
                               ,:new.is_compiled);
  end if;
 end sdd_workareas_u;
/

create or replace trigger sdd_workareas_d
 instead of delete on sdd_workareas
 for each row
 declare
 begin
  jr_workarea.delete_workarea(:old.irid);
 end sdd_workareas_d;
/

