Oracle觸發器的一個簡單例子

用戶狀態變成離職狀態,系統配置表被觸發,修改配置表狀態 

create or replace trigger BASEDB_USERLEFT
  before update or delete on basedb_users 
  for each row
declare
  -- local variables here
  varcount number;
begin
    --select loginid into userloginid from basedb_users where status=:new.status;
    if updating or deleting then
      select count(*) into varcount from basedb_sysconfuser where loginid=:new.loginid;
        if varcount>0 and :new.status='5' then
            update basedb_sysconfuser set isvalid='0',last_date=sysdate,action_sign='U' where loginid=:new.loginid;
        end if;  
    end if;

end BASEDB_USERLEFT;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章