或者有没有更好的写法。o(︶︿︶)o 唉!
create or replace procedure proc_CalculationWorkDate
(
? plan_date in date,--登录日期
? flag in number,--1 往前日期,0往后日期
? date_number in number,--天数
? out_date out date--计算出的日期
)
is
? dayOfWeek number:=0;--星期的数字
? dates number:=date_number;--往前或者往后的天数(包含工作日的)初始化给他等于天数
? i int:=0;
? j int:=0;
begin
? if flag=1 then--计算往前日期
? ? ? while i
? ? ? ? if dayOfWeek=1 or dayOfWeek=7 then --周六 周日
? ? ? ? ? dates:=dates+1;
? ? ? ? ? i:=i;
? ? ? ? ? j:=j+1;
? ? ? ? else
? ? ? ? end if;
? ? ? end loop;
? ? ? select plan_date+dates into out_date from dual;
? ? ? --DBMS_OUTPUT.PUT_LINE(dates);
? end if;
? if flag=0 then --计算往后日期
? ? ? while i
? ? ? ? if dayOfWeek=1 or dayOfWeek=7 then
? ? ? ? ? dates:=dates+1;
? ? ? ? ? i:=i;
? ? ? ? ? j:=j+1;
? ? ? ? else
? ? ? ? ? i:=i+1;
? ? ? ? end if;
? ? ? end loop;
? ? ? select plan_date-dates into out_date from dual;
? ? ? --DBMS_OUTPUT.PUT_LINE(dates);
? end if;
end;