CREATE OR REPLACE FUNCTION CalWorkingDays
(
StartDate in date,
EndDate in date,
TotalDays in integer
)
RETURN integer IS
v_id int;
FreeDays integer;
DaoJiS integer;
BEGIN
if TotalDays<>0 then
v_id:=-1;
dbms_output.put_line('The value of TotalDays must be up to 0');
exit;
end if;
if TotalDays<FreeDays then
v_id:=-1;
exit;
end if;
if StartDate>EndDate then
v_id:=-1;
exit;
end if;
select count(*) into FreeDays from V_JIEJIARI where jiejiari between StartDate and EndDate;
DaoJiS := TotalDays - FreeDays;
RETURN DaoJiS;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
RAISE;
END CalWorkingDays;
/
PLS-00376: 非法 EXIT 语句;它必须出现在一个循环中
(
StartDate in date,
EndDate in date,
TotalDays in integer
)
RETURN integer IS
v_id int;
FreeDays integer;
DaoJiS integer;
BEGIN
if TotalDays<>0 then
v_id:=-1;
dbms_output.put_line('The value of TotalDays must be up to 0');
exit;
end if;
if TotalDays<FreeDays then
v_id:=-1;
exit;
end if;
if StartDate>EndDate then
v_id:=-1;
exit;
end if;
select count(*) into FreeDays from V_JIEJIARI where jiejiari between StartDate and EndDate;
DaoJiS := TotalDays - FreeDays;
RETURN DaoJiS;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
RAISE;
END CalWorkingDays;
/
PLS-00376: 非法 EXIT 语句;它必须出现在一个循环中
FETCH c1 INTO c1_rec;
EXIT WHEN c1%NOTFOUND;
IF c1_rec.teamcode = tmpstr1 THEN
retVal := 1;
EXIT;
END IF;
END LOOP;
return v_id ;代替exit就可以了
exit是用在循环里面的