begin
l_CURRENT_DATE := P_FROM_DATE;
select P_TO_DATE - P_FROM_DATE into l_DAY_COUNT from dual;
-- while l_CURRENT_DATE between P_FROM_DATE and P_TO_DATE loop
for i in 0 .. l_DAY_COUNT loop
-- l_CURRENT_DATE := P_FROM_DATE + i;
select to_number(to_char(l_CURRENT_DATE, 'd'))
into l_DAY_NUMBER
from dual;
-------------------------------------
if l_DAY_NUMBER = 1 and P_DAY1 = 1 then
select 1
into l_DUMMY
from dual
where exists (select *
from PBG_PARK_BOOKING
where BOOKING_DATE = l_CURRENT_DATE
and NUM1 = P_PARK
and FROM_TIME = P_FROM_TIME
and TO_TIME = P_TO_TIME);
if l_DUMMY is not null then
return('PBG-ERROR410:Please Inform there is an Conflict with other Resevation..');
end if;
end if;
l_DUMMY := '';
--------------------------------------
if l_DAY_NUMBER = 2 and P_DAY2 = 2 then
select 1
into l_DUMMY
from dual
where exists (select *
from PBG_PARK_BOOKING
where BOOKING_DATE = l_CURRENT_DATE
and NUM1 = P_PARK
and FROM_TIME = P_FROM_TIME
and TO_TIME = P_TO_TIME);
if l_DUMMY is not null then
return('PBG-ERROR410:Please Inform there is an Conflict with other Resevation..');
end if;
end if;
l_DUMMY := '';
end loop
exception
when no_data_found then
return null;
end ;
答案 0 :(得分:0)
您发布的代码不完整;有一些从未声明过的变量(或参数)(例如P_TO_DATE
,P_FROM_DATE
等)。
无论如何:说该代码“拒绝”检查IF
语句(我相信您是说它实际上是执行 IF
,但在{{1 }}中的内容并直接进入异常处理部分,意味着SELECT
不返回任何内容(即引发SELECT
)。
如果您不希望发生这种情况,请确保NO_DATA_FOUND
返回某物。
另一方面,看到您编写了一个循环,也许您想检查所有SELECT
索引,即,如果它在第一个索引上失败了,那就好了-请检查第二个索引,依此类推。 / p>
如果是这样,则应将循环内的代码包含在其自己的FOR LOOP
块中:
BEGIN-EXCEPTION-END