Chinaunix首页 | 论坛 | 博客
  • 博客访问: 269885
  • 博文数量: 42
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 534
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-26 19:11
文章分类
文章存档

2014年(42)

我的朋友

分类: 数据库开发技术

2014-06-07 14:06:44

-- update 操作的触发器例子
drop trigger if exists csf_maec.tri_economic_dt_update;
delimiter |
create trigger csf_maec.tri_economic_dt_update after update on csf_maec.maec_data
for each row begin   
    insert into csf_maec.maec_data_ecnomic(
       data_id, data_value, audit_status, data_notes, insert_user,
       insert_time, update_user, update_time, delete_user, delete_time,
       audit_user, audit_time, op_flag
    )  
    select new.data_id, new.data_value, new.audit_status, new.data_notes, new.insert_user,
       new.insert_time, new.update_user, now(), new.delete_user, new.delete_time,
       new.audit_user, new.audit_time, concat('update ',user());
         
end|
delimiter ;


-- insert操作的触发器例子
drop trigger if exists csf_maec.tri_economic_dt_insert;
delimiter |
create trigger csf_maec.tri_economic_dt_insert after insert on csf_maec.maec_data
for each row begin   
    insert into csf_maec.maec_data_ecnomic(
       data_id, data_value, audit_status, data_notes, insert_user,
       insert_time, update_user, update_time, delete_user, delete_time,
       audit_user, audit_time, op_flag
    )  
    select new.data_id, new.data_value, new.audit_status, new.data_notes, new.insert_user,
       new.insert_time, new.update_user, new.update_time, new.delete_user, new.delete_time,
       new.audit_user, new.audit_time, concat('insert ',user());
         
end|
delimiter ;


-- delete操作的触发器例子
drop trigger if exists csf_maec.tri_economic_dt_delete;
delimiter |
create trigger csf_maec.tri_economic_dt_delete after delete on csf_maec.maec_data
for each row begin   
    insert into csf_maec.maec_data_ecnomic(
       data_id, data_value, audit_status, data_notes, insert_user,
       insert_time, update_user, update_time, delete_user, delete_time,
       audit_user, audit_time, op_flag
    )  
    select old.data_id, old.data_value, old.audit_status, old.data_notes, old.insert_user,
       old.insert_time, old.update_user, old.update_time, old.delete_user, now(),
       old.audit_user, old.audit_time,  concat('delete ',user());
         
end|
delimiter ;
阅读(4278) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~