我只是在学习plsql ..我创建了一个函数,该函数从给定参数“ THEDAY”递归返回非假期的日期(它将搜索非假期的第二天),但是它不起作用。我不知道为什么它仍然返回假期。
FUNCTION WEEKDAY(THEDAY IN OUT DATE)
RETURN DATE
IS
count_row number;
nextday DATE;
isholiday boolean;
BEGIN
nextday := THEDAY;
isholiday := false;
IF (TO_CHAR(TO_DATE(THEDAY),'DY','nls_date_language=american')='SAT') THEN
nextday := THEDAY + 2;
isholiday := true;
ELSIF((TO_CHAR(TO_DATE(THEDAY),'DY','nls_date_language=american')='SUN') ) THEN
nextday := THEDAY +1;
isholiday := true;
ELSE
BEGIN
SELECT count(*)
INTO count_row
FROM TBL_MSTHOLIDAYS
WHERE trunc(DDAY) = trunc(THEDAY);
IF count_row <> 0 THEN
nextday := THEDAY+1;
isholiday := true;
END IF;
END;
END IF;
if (isholiday = true) THEN
RETURN WEEKDAY(nextday);
ELSE
RETURN THEDAY;
END IF;
END;