oracle存储过程

create or replace procedure Proc_Update_StaffInfo
is
  temp number;
  cursor cur_staff is select * from HR_RS_Staff where Deleted = 0 and sysdate > EntryTime + 365;
begin
    for u in cur_staff
      loop
        temp :=  mod(floor(sysdate - to_date(u.EntryTime,'yyyy-MM-dd')),365);

        if temp <> 0 then
          -- 员工企龄
          update HR_RS_Staff set EnterprisesAge = EnterprisesAge + 1 where ID = u.ID;
         
          -- 员工年假信息
          select count(*) into temp from HR_KQ_StaffAnnualLeave where ID = u.ID;
          if temp = 0 then
            insert into HR_KQ_StaffAnnualLeave(ID, Staffid, Numberofdays, Deleted, Createtime, Modifytime)values(u.ID, u.ID, 5, 0, sysdate, sysdate);
          else
            update HR_KQ_StaffAnnualLeave set Numberofdays = 40 where ID = u.ID;
          end if;
        end if;
      end loop;
end;

posted @ 2013-03-01 11:20  awp110  阅读(151)  评论(0编辑  收藏  举报