For loop is not working inside program

Profile: shyamkrish
Tags:
Oracle
PL/SQL
Hi, I would like to get below output If the input is 12-Aug-2016 the output should be 16-Aug-2016. But I'm getting 15-Aug-2016 a soutput which is offshore holiday. so created for loop it checks v_dt = holiday_date if it matches then it will increment by 1 v_dt:=v_dt+1 else v_dt but this loop is not working... can any one let me know where is the issue..
Declare

input_dt date := '&Dt';

in_dt date := input_dt+1;

v_dt date;

v_chk number;

cursor c1 is select HOLIDAY_DATE,HOLIDAY_NAME from Holiday_LIST where HOLIDAY_DATE=in_dt;

begin

select count(1) into v_chk from Holiday_LIST where HOLIDAY_DATE=in_dt;

if v_chk > 0 then

in_dt := in_dt+1;

end if;

select decode(to_char(in_dt,'DY'),'SAT',in_dt+2,'SUN',in_dt+1,in_dt)

into v_dt from dual;

--dbms_output.put_line(v_dt);

FOR i IN c1

loop

IF v_dt = i.HOLIDAY_DATE

THEN

DBMS_OUTPUT.put_line ('HOLIDAY FOUND:');

v_dt := v_dt+1;

dbms_output.put_line('the o/p is' ||v_dt);

else

dbms_output.put_line(v_dt);

end if;

end loop;

end;

Reply to this discussion

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members reply.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: