oracle序列及触发器

发布时间:2014-10-23 23:24:26
来源:分享查询网

//oracle序列和触发器实现表主键自增 create sequence seq_gsset; create or replace trigger tr_gsset before insert on gsset  for each row begin select seq_gsset.nextval into :new.id from dual; end; //插入数据触发器 create or replace trigger trig_appeal  after insert on appeal for each row begin update zgkhzb set appealID=:new.id where id=:new.khid; end; //删除数据触发器 create or replace trigger del_performance  before delete on performance for each row begin   if(:old.khzhuti=1 and (:old.khtype=1 or :old.khtype=2)) then      delete yzkhwd where uuid=:old.weidu;   end if;   if(:old.khzhuti=1 and :old.khtype=3) then      delete yzzxkhwd where uuid=:old.weidu;   end if;   if(:old.khzhuti=2 and (:old.khtype=1 or :old.khtype=2)) then      delete zgkhwd where uuid=:old.weidu;   end if;   if(:old.khzhuti=2 and :old.khtype=3) then      delete zgzxkhwd where uuid=:old.weidu;   end if; end;

返回顶部
查看电脑版