为EMP表创建一个触发器:当员工工资被更改并且工资总和低于5000时,输出 20
RT,用oracle来创建!!急谢谢雪狼【王者】的回答,但是“ifa+b<5000then--这个自己写个求和的”这个地方能不能写具体点,我刚开始学这个不是很会。。谢谢...
RT,用oracle来创建!!急
谢谢 雪狼【王者】的回答,但是“if a+b<5000 then --这个自己写个求和的”这个地方能不能写具体点,我刚开始学这个不是很会。。谢谢 展开
谢谢 雪狼【王者】的回答,但是“if a+b<5000 then --这个自己写个求和的”这个地方能不能写具体点,我刚开始学这个不是很会。。谢谢 展开
1个回答
展开全部
create or replace trigger test_tri before update on EMP for each rowdeclare a number; b number; begin a:=:new.工资1; b:=:new.工资2; if a+b<5000 then --这个自己写个求和的 dbms_output.put_line('工资总量低于5000的信息'); end if;end test_tri;
你没打完吧,我猜输出后面你想打“工资总量低于5000的信息”。
下面是建立表触发器的代码:create or replace trigger tg_E_CONTACTbefore update or insert or delete on E_CONTACTfor each rowbeginif inserting theninsert into E_CONTACT@gaac.worldvalues(:new.TELEPHONE, :new.EMPLOYEEID, :new.STATUS);elseif updating thenupdate E_CONTACT@gaac.world sset s.TELEPHONE = :new.TELEPHONE,s.EMPLOYEEID = :new.EMPLOYEEID,s.STATUS = :new.STATUSwhere s.employeeid = :old.employeeid;elseif deleting thendelete from E_CONTACT@gaac.world swhere s.employeeid = :old.employeeid;end if;end if;end if;end;下面是建立视图触发器的代码:(注意里面的instead of)create or replace trigger tg_E_CONTACTbefore instead of update or instead of insert or instead of delete on E_CONTACTfor each rowbeginif inserting theninsert into E_CONTACT@gaac.worldvalues(:new.TELEPHONE, :new.EMPLOYEEID, :new.STATUS);elseif updating thenupdate E_CONTACT@gaac.world sset s.TELEPHONE = :new.TELEPHONE,s.EMPLOYEEID = :new.EMPLOYEEID,s.STATUS = :new.STATUSwhere s.employeeid = :old.employeeid;elseif deleting thendelete from E_CONTACT@gaac.world swhere s.employeeid = :old.employeeid;end if;end if;end if;end;
希望对你有帮助^_^
你没打完吧,我猜输出后面你想打“工资总量低于5000的信息”。
下面是建立表触发器的代码:create or replace trigger tg_E_CONTACTbefore update or insert or delete on E_CONTACTfor each rowbeginif inserting theninsert into E_CONTACT@gaac.worldvalues(:new.TELEPHONE, :new.EMPLOYEEID, :new.STATUS);elseif updating thenupdate E_CONTACT@gaac.world sset s.TELEPHONE = :new.TELEPHONE,s.EMPLOYEEID = :new.EMPLOYEEID,s.STATUS = :new.STATUSwhere s.employeeid = :old.employeeid;elseif deleting thendelete from E_CONTACT@gaac.world swhere s.employeeid = :old.employeeid;end if;end if;end if;end;下面是建立视图触发器的代码:(注意里面的instead of)create or replace trigger tg_E_CONTACTbefore instead of update or instead of insert or instead of delete on E_CONTACTfor each rowbeginif inserting theninsert into E_CONTACT@gaac.worldvalues(:new.TELEPHONE, :new.EMPLOYEEID, :new.STATUS);elseif updating thenupdate E_CONTACT@gaac.world sset s.TELEPHONE = :new.TELEPHONE,s.EMPLOYEEID = :new.EMPLOYEEID,s.STATUS = :new.STATUSwhere s.employeeid = :old.employeeid;elseif deleting thendelete from E_CONTACT@gaac.world swhere s.employeeid = :old.employeeid;end if;end if;end if;end;
希望对你有帮助^_^
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询