How to execute trigger instead of view while changes are done on a field in the table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • marieoutayek
    New Member
    • Jun 2008
    • 1

    How to execute trigger instead of view while changes are done on a field in the table

    Hi,

    I have a problem and I hope that you help me :

    I have a trigger "tr_view_emp_iu " INSTEAD OF a view "view_emplo yee" the problem is if the changes is done on the field "first_name " in the table "employee" the trigger "tr_view_emp_iu " will not be executed.


    create or replace view view_employee as
    select e.emp_id, e.first_Name, e.last_name
    from employee e
    order by e.first_Name
    ;

    create or replace trigger tr_view_emp_iu
    INSTEAD OF UPDATE
    on view_employee
    declare
    view_error VARCHAR2(256);
    begin
    if updating('first _name')
    then
    update employee
    set First_Name = :new.First_Name
    where emp_id = :old.emp_id;
    end if;
    end
    ;


    My question is : How to make the trigger tr_view_emp_iu executable when changes will be done on the field "first_name " of the table "employee" related to the view "view_emplo yee" not changes in the view itself but in the table of the view ?

    N.B: THE VIEW IS READ ONLY

    Regards,
    Marie
Working...