日期:2014-05-16  浏览次数:20523 次

触发器例子
create or replace trigger userupdate


  after insert or update or delete on users


  for each row


begin


  if inserting then


    insert into user_log


      (description, user_id, new_user_name,update_time)


    values


      ('inserting', :new.user_id, :new.user_name,sysdate);


  else if updating then


    insert into user_log


      (description, user_id, old_user_name, new_user_name,update_time)


    values


      ('updating', :new.user_id, :old.user_name, :new.user_name,sysdate);


  else insert


      into user_log(description, user_id, new_user_name,update_time) values('deleting',:old.user_id,:old.user_name,sysdate);


  end if;


end userupdate;