自定义记录类型游标(二)

2014-11-24 09:06:36 · 作者: · 浏览: 1
核定年休假天数 := 10;
elsif (工龄 > 10 * 12) then
核定年休假天数 := 5 * (1 - (工龄 - 120) / 12) + 10 * ((工龄 - 120) / 12);
elsif (工龄 > 24) then
核定年休假天数 := 5; --判断小于10年的为5天
elsif (工龄 > 12) then
核定年休假天数 := 5 * (工龄 - 12) / 12; --判断小于10年的为5天
else
核定年休假天数 := 0;
end if;
else
--近公司不足一年的
if (工龄 > 21 * 12) then
--判断大于21年的 司龄界点
核定年休假天数 := 15 * (司龄) / 12;
elsif (工龄 > 20 * 12) then
--判断大于20 可能出现工龄、司龄界点
--判断先出现 工龄界点还是司龄界点
if ((工龄 - 240) > (司龄)) then
--工龄月份早 如工龄 3月 司龄 5月
核定年休假天数 := 15 * ((司龄) / 12);
elsif ((司龄) < (工龄 - 240)) then
--工龄月份早 如司龄 5月 工龄 7月
核定年休假天数 := 10 * ((工龄 - 240 + 司龄) / 12) + 15 * (工龄 - 240) / 12;
end if;
elsif (工龄 > 11 * 12) then
--判断大于11年
核定年休假天数 := 10;
elsif (工龄 > 10 * 12) then
--判断大于10年 可能出现工龄、司龄界点
--判断先出现 工龄界点还是司龄界点
if ((工龄 - 120) > (司龄)) then
--工龄月份早 如工龄 3月 司龄 5月
核定年休假天数 := 10 * ((司龄) / 12);
elsif ((司龄) < (工龄 - 120)) then
--工龄月份早 如司龄 5月 工龄 7月
核定年休假天数 := 5 * ((工龄 - 120 + 司龄) / 12) + 10 * (工龄 - 120) / 12;
end if;
elsif (工龄 > 24) then
核定年休假天数 := 5; --判断小于10年的为5天
elsif (工龄 > 12) then
--核定年休假天数:=5 * (1-(工龄 -12)/12); --判断小于10年的为5天
if ((工龄 - 12) >= (司龄)) then
--工龄月份早 如工龄 3月 司龄 5月
核定年休假天数 := 5 * ((司龄) / 12);
else
--工龄月份早 如司龄 5月 工龄 7月
核定年休假天数 := 5 * (工龄 - 12) / 12;
end if;
else
核定年休假天数 := 0;
end if;
end if;
end if;
-- 统计当年最后一天
核定年度最后一天 := to_date(year || '1231', 'yyyyMMdd');
核定年度第一天 := to_date(year || '0101', 'yyyyMMdd');
-- 如果是统计当年入司,计算剩余日历
if (aaa.joindate <= 核定年度最后一天 and 核定年度第一天 <= aaa.joindate) then
-- 剩余天数
核定年度剩余天数 := trunc((((86400 * (核定年度最后一天 - aaa.joindate)) / 60) / 60) / 24);
核定年休假天数 := trunc(核定年休假天数 * 核定年度剩余天数 / 365);
end if;
select count(*) into num4 from GCAttendLeave where StatYear = year and EmpID = aaa.empid;
if (num4 > 0) then
Update GCAttendLeave Set AnnualLeaveI = trunc(核定年休假天数), ynxjleavei = nvl(upyearDay, 0.0) where EmpID = aaa.empid and StatYear = year;
else
INSERT INTO GCAttendLeave(EmpID, StatYear, AnnualLeaveI, ynxjleavei) VALUES(aaa.empid, year, trunc(核定年休假天数), nvl(upyearDay, 0.0));
end if;
END Loop;
close empIdResult;
END;
end;