I need to insert data into new target table from jan1st to march28th by iterating through dates in Oracle SQL.
I have tried below script, bt its throwing errors
DECLARE
from_dt DATE := to_date('01/01/2019', 'mm/dd/yyyy');
to_dt DATE := to_date('01/04/2019', 'mm/dd/yyyy');
fin_dt DATE := to_date('03/28/2019', 'mm/dd/yyyy');
begin
while (from_dt < fin_dt)
loop
insert into New_target_table as select /*statement*/
and greatest(CE.UPDATE_TS, CES.Update_ts) > from_dt
and greatest(CE.UPDATE_TS, CES.Update_ts) < to_dt ;
end loop;
set from_dt:= from_dt + 3;
set to_dt := DATEADD(DAY, 3, from_dt);
END;