oracle 插入每年每天数据

时间:2024-07-24 18:04:14
create or replace procedure PROC_P_ABC is

v_sumday number :=0;
i number :=0;
v_calendar_date number :=null;
v_day number :=null; begin select to_date(TO_CHAR(SYSDATE,'RRRR'),'yyyy') - to_date(TO_CHAR(SYSDATE,'RRRR')-1,'yyyy') INTO v_sumday from dual; while i < v_sumday LOOP --begin
SELECT TO_CHAR(TRUNC(SYSDATE, 'y') + i, 'YYYYMMDD') into v_calendar_date FROM DUAL;
SELECT TO_CHAR(TO_DATE(TRUNC(SYSDATE, 'y') + i , 'yyyy-mm-dd'),'d') into v_day from dual; IF v_day = 4 THEN
insert into t_p_scf_book_calendar
(calendar_date, weekly_flag, daily_flag,flow_code_weekly)
values
(v_calendar_date, 1, 8, v_calendar_date || 'W03'); ELSE
insert into t_p_scf_book_calendar
(calendar_date, weekly_flag, daily_flag)
values
(v_calendar_date, 0, 8); END IF; i:= i + 1; --end; end LOOP; end PROC_P_ABC;