How to iterate over a date range in PL/SQL

前端 未结 7 1923
梦毁少年i
梦毁少年i 2020-12-29 12:56

I need to write a report that generates summary totals against a table with date ranges for each record.

table data:
option   start_date   end_date
opt1              


        
7条回答
  •  一个人的身影
    2020-12-29 13:26

    declare 
    v_curr_date  date;
    for i in to_number(to_char(p_date_from ,'j')) .. to_number(to_char(p_date_to 
    ,'j')) loop
    
     v_curr_date = to_date(to_char(i),'j'); 
     --make any operation on v_curr_date (like insert into table)
    
    end loop;    
    
    end;
    

提交回复
热议问题