User:Amarendranath1998

CREATE OR REPLACE Function test1 (input_date In Date) Return Date As v_Dt_input Date; v_c_flag Char:='F'; v_n_cnt Number; v_dt_dcmh_holiday_date Date; v Varchar2(1000); y Varchar2(1000);

Begin v := trim(to_char(input_date,'DAY')) ; If (v = 'SATURDAY') Then v_Dt_input := input_date + 2; Elsif (v = 'SUNDAY') Then v_Dt_input := input_date + 1; Else v_Dt_input := input_date ; End If; Loop Exit When v_c_flag = 'T'; Begin Select Count(1) Into v_n_cnt From t_com_holiday_mst m          Where m.cmh_holiday_date = v_Dt_input; Exception When no_data_found Then v_c_flag := 'T'; End; If v_n_cnt = 0 Then v_c_flag := 'T' ; Else v_Dt_input := v_Dt_input + 1 ; v_c_flag := 'F'; End If; If (trim(to_char(v_Dt_input,'DAY')) = 'SUNDAY') Then v_Dt_input := v_Dt_input + 1; v_c_flag := 'F'; Elsif (trim(to_char(v_Dt_input,'DAY')) = 'SATURDAY') Then v_Dt_input := v_Dt_input + 2; v_c_flag := 'F'; Else v_Dt_input := v_Dt_input ; End If; End Loop; Return v_Dt_input; Exception When Others Then dbms_output.put_line(Sqlerrm||' ' ||Sqlcode); End;