[Home] [Help]
551: 2 inc refresh
552: */
553: function check_for_inc_refresh return number is
554: --
555: /*cursor c1 is select 1 from bsc_db_calendar,bsc_sys_calendars_b where edw_calendar_type_id=1 and edw_calendar_id =1001
556: and bsc_db_calendar.calendar_id=bsc_sys_calendars_b.calendar_id and rownum=1;
557: cursor c2 is select 1 from mlog$_fii_time_day where rownum=1;
558: cursor c3 is select 1 from mlog$_fii_time_day where dmltype$$ <>'I' and rownum=1;
559: */
552: */
553: function check_for_inc_refresh return number is
554: --
555: /*cursor c1 is select 1 from bsc_db_calendar,bsc_sys_calendars_b where edw_calendar_type_id=1 and edw_calendar_id =1001
556: and bsc_db_calendar.calendar_id=bsc_sys_calendars_b.calendar_id and rownum=1;
557: cursor c2 is select 1 from mlog$_fii_time_day where rownum=1;
558: cursor c3 is select 1 from mlog$_fii_time_day where dmltype$$ <>'I' and rownum=1;
559: */
560: --
565: c3 CurTyp;
566: l_res number;
567: Begin
568: l_res:=null;
569: l_stmt:='select 1 from bsc_db_calendar,bsc_sys_calendars_b where edw_calendar_type_id=1 and edw_calendar_id =1001
570: and bsc_db_calendar.calendar_id=bsc_sys_calendars_b.calendar_id and rownum=1';
571: if g_debug then
572: write_to_log_file_n(l_stmt);
573: end if;
566: l_res number;
567: Begin
568: l_res:=null;
569: l_stmt:='select 1 from bsc_db_calendar,bsc_sys_calendars_b where edw_calendar_type_id=1 and edw_calendar_id =1001
570: and bsc_db_calendar.calendar_id=bsc_sys_calendars_b.calendar_id and rownum=1';
571: if g_debug then
572: write_to_log_file_n(l_stmt);
573: end if;
574: open c1 for l_stmt;
645: --
646: l_error varchar2(4000);
647: --
648: Begin
649: --bsc_sys_calendars_b,bsc_sys_calendars_tl,bsc_sys_periods,bsc_sys_periods_tl,bsc_sys_periodicities
650: if g_debug then
651: write_to_log_file_n('In load_dbi_cal_into_bsc_full '||get_time);
652: end if;
653: --get the dbi cal info into memory
697: procedure load_dbi_cal_into_bsc_inc is
698: --
699: --
700: Begin
701: --bsc_sys_calendars_b,bsc_sys_calendars_tl,bsc_sys_periods,bsc_sys_periods_tl,bsc_sys_periodicities
702: if g_debug then
703: write_to_log_file_n('In load_dbi_cal_into_bsc_inc '||get_time);
704: end if;
705: --get the dbi cal info into memory
783: procedure init_cal_per_ids is
784: --
785: cursor c1(p_cal_id number) is select bsc_sys_periodicities.calendar_id,
786: bsc_sys_periodicities.periodicity_id,bsc_sys_periodicities.period_type_id ,
787: bsc_sys_calendars_b.short_name, bsc_sys_periodicities.short_name,bsc_sys_calendars_b.fiscal_change
788: from bsc_sys_periodicities ,bsc_sys_calendars_b
789: where bsc_sys_periodicities.calendar_id=bsc_sys_calendars_b.calendar_id
790: and bsc_sys_calendars_b.edw_calendar_type_id=1 and bsc_sys_calendars_b.edw_calendar_id=p_cal_id;
791: --
784: --
785: cursor c1(p_cal_id number) is select bsc_sys_periodicities.calendar_id,
786: bsc_sys_periodicities.periodicity_id,bsc_sys_periodicities.period_type_id ,
787: bsc_sys_calendars_b.short_name, bsc_sys_periodicities.short_name,bsc_sys_calendars_b.fiscal_change
788: from bsc_sys_periodicities ,bsc_sys_calendars_b
789: where bsc_sys_periodicities.calendar_id=bsc_sys_calendars_b.calendar_id
790: and bsc_sys_calendars_b.edw_calendar_type_id=1 and bsc_sys_calendars_b.edw_calendar_id=p_cal_id;
791: --
792: l_cal_id number;
785: cursor c1(p_cal_id number) is select bsc_sys_periodicities.calendar_id,
786: bsc_sys_periodicities.periodicity_id,bsc_sys_periodicities.period_type_id ,
787: bsc_sys_calendars_b.short_name, bsc_sys_periodicities.short_name,bsc_sys_calendars_b.fiscal_change
788: from bsc_sys_periodicities ,bsc_sys_calendars_b
789: where bsc_sys_periodicities.calendar_id=bsc_sys_calendars_b.calendar_id
790: and bsc_sys_calendars_b.edw_calendar_type_id=1 and bsc_sys_calendars_b.edw_calendar_id=p_cal_id;
791: --
792: l_cal_id number;
793: l_cal_short_name varchar2(100);
786: bsc_sys_periodicities.periodicity_id,bsc_sys_periodicities.period_type_id ,
787: bsc_sys_calendars_b.short_name, bsc_sys_periodicities.short_name,bsc_sys_calendars_b.fiscal_change
788: from bsc_sys_periodicities ,bsc_sys_calendars_b
789: where bsc_sys_periodicities.calendar_id=bsc_sys_calendars_b.calendar_id
790: and bsc_sys_calendars_b.edw_calendar_type_id=1 and bsc_sys_calendars_b.edw_calendar_id=p_cal_id;
791: --
792: l_cal_id number;
793: l_cal_short_name varchar2(100);
794: l_per_id number;
798: --
799: Begin
800: if g_debug then
801: write_to_log_file_n('select bsc_sys_periodicities.periodicity_id,bsc_sys_periodicities.period_type_id '||
802: 'from bsc_sys_periodicities ,bsc_sys_calendars_b '||
803: 'where bsc_sys_periodicities.calendar_id=bsc_sys_calendars_b.calendar_id '||
804: 'and bsc_sys_calendars_b.edw_calendar_type_id=1 and bsc_sys_calendars_b.edw_calendar_id=1001/1002/1003 ');
805: end if;
806: open c1(1001);
799: Begin
800: if g_debug then
801: write_to_log_file_n('select bsc_sys_periodicities.periodicity_id,bsc_sys_periodicities.period_type_id '||
802: 'from bsc_sys_periodicities ,bsc_sys_calendars_b '||
803: 'where bsc_sys_periodicities.calendar_id=bsc_sys_calendars_b.calendar_id '||
804: 'and bsc_sys_calendars_b.edw_calendar_type_id=1 and bsc_sys_calendars_b.edw_calendar_id=1001/1002/1003 ');
805: end if;
806: open c1(1001);
807: loop
800: if g_debug then
801: write_to_log_file_n('select bsc_sys_periodicities.periodicity_id,bsc_sys_periodicities.period_type_id '||
802: 'from bsc_sys_periodicities ,bsc_sys_calendars_b '||
803: 'where bsc_sys_periodicities.calendar_id=bsc_sys_calendars_b.calendar_id '||
804: 'and bsc_sys_calendars_b.edw_calendar_type_id=1 and bsc_sys_calendars_b.edw_calendar_id=1001/1002/1003 ');
805: end if;
806: open c1(1001);
807: loop
808: fetch c1 into l_cal_id,l_per_id,l_per_type_id, l_cal_short_name, l_per_short_name,l_fiscal_change;
1584: end if;
1585: --cal
1586: --for ENT calendar, the EDW_CALENDAR_TYPE_ID is set to 2.
1587: --for period 445 and greg , this flag is set to 1
1588: insert into bsc_sys_calendars_b(CALENDAR_ID,EDW_FLAG,EDW_CALENDAR_ID,EDW_CALENDAR_TYPE_ID,
1589: FISCAL_YEAR,FISCAL_CHANGE,RANGE_YR_MOD,CURRENT_YEAR,START_MONTH,START_DAY,CREATED_BY,CREATION_DATE,
1590: LAST_UPDATED_BY,LAST_UPDATE_DATE,LAST_UPDATE_LOGIN, short_name) values (
1591: g_ent_cal_id,0,1001,1,g_bsc_greg_fiscal_year,g_ent_fiscal_change,0,l_ent_current_year,
1592: l_ent_start_month,l_ent_start_day,g_who,sysdate,g_who,sysdate,g_who, 'TIME');
1953: end if;
1954:
1955: /* CREATE 445 CALENDAR */
1956:
1957: insert into bsc_sys_calendars_b(CALENDAR_ID,EDW_FLAG,EDW_CALENDAR_ID,EDW_CALENDAR_TYPE_ID,
1958: FISCAL_YEAR,FISCAL_CHANGE,RANGE_YR_MOD,CURRENT_YEAR,START_MONTH,START_DAY,CREATED_BY,CREATION_DATE,
1959: LAST_UPDATED_BY,LAST_UPDATE_DATE,LAST_UPDATE_LOGIN, SHORT_NAME) values (
1960: g_445_cal_id,0,1002,1,g_bsc_greg_fiscal_year,g_445_fiscal_change,0,l_445_current_year,
1961: l_445_start_month,l_445_start_day,g_who,sysdate,g_who,sysdate,g_who, g_445_cal_short_name);
2242: write_to_log_file_n('l_greg_current_year='||l_greg_current_year||',l_greg_start_month='||
2243: l_greg_start_month||',l_greg_start_day='||l_greg_start_day);
2244: end if;
2245: --cal
2246: insert into bsc_sys_calendars_b(CALENDAR_ID,EDW_FLAG,EDW_CALENDAR_ID,EDW_CALENDAR_TYPE_ID,
2247: FISCAL_YEAR,FISCAL_CHANGE,RANGE_YR_MOD,CURRENT_YEAR,START_MONTH,START_DAY,CREATED_BY,CREATION_DATE,
2248: LAST_UPDATED_BY,LAST_UPDATE_DATE,LAST_UPDATE_LOGIN, SHORT_NAME) values (
2249: g_greg_cal_id,0,1003,1,g_bsc_greg_fiscal_year,g_greg_fiscal_change,0,l_greg_current_year,
2250: l_greg_start_month,l_greg_start_day,g_who,sysdate,g_who,sysdate,g_who, g_greg_cal_short_name);
2445: End;
2446:
2447: procedure delete_dbi_calendar_metadata is
2448: ---
2449: cursor c1 is select calendar_id from bsc_sys_calendars_b where edw_calendar_type_id in (1) and
2450: edw_calendar_id in (1001,1002,1003);
2451: ---
2452: l_calendar_id number;
2453: Begin
2454: if g_debug then
2455: write_to_log_file_n('In delete_dbi_calendar_metadata'||get_time);
2456: end if;
2457: if g_debug then
2458: write_to_log_file_n('select calendar_id from bsc_sys_calendars_b where edw_calendar_type_id in (1) and
2459: edw_calendar_id in (1001,1002,1003)');
2460: end if;
2461: open c1;
2462: loop
2485: if g_debug then
2486: write_to_log_file_n('Deleted '||sql%rowcount||' rows '||get_time);
2487: end if;
2488: if g_debug then
2489: write_to_log_file_n('delete bsc_sys_calendars_b where calendar_id='||l_calendar_id||');'||get_time);
2490: end if;
2491: delete bsc_sys_calendars_b where calendar_id=l_calendar_id;
2492: if g_debug then
2493: write_to_log_file_n('Deleted '||sql%rowcount||' rows '||get_time);
2487: end if;
2488: if g_debug then
2489: write_to_log_file_n('delete bsc_sys_calendars_b where calendar_id='||l_calendar_id||');'||get_time);
2490: end if;
2491: delete bsc_sys_calendars_b where calendar_id=l_calendar_id;
2492: if g_debug then
2493: write_to_log_file_n('Deleted '||sql%rowcount||' rows '||get_time);
2494: end if;
2495: end loop;
2501:
2502: procedure delete_dbi_calendars
2503: is
2504: ---
2505: cursor c1 is select calendar_id from bsc_sys_calendars_b where edw_calendar_type_id in (1) and
2506: edw_calendar_id in (1001,1002,1003);
2507: ---
2508: l_calendar_id number;
2509: Begin
2510: if g_debug then
2511: write_to_log_file_n('In delete_dbi_calendars'||get_time);
2512: end if;
2513: if g_debug then
2514: write_to_log_file_n('select calendar_id from bsc_sys_calendars_b where edw_calendar_type_id in (1) and
2515: edw_calendar_id in (1001,1002,1003)');
2516: end if;
2517: open c1;
2518: loop
2903: End;
2904:
2905: procedure get_ent_cal_start_date(p_mode varchar2) is
2906: --
2907: cursor c1 is select start_month||'/'||start_day||'/'||current_year from bsc_sys_calendars_b
2908: where edw_calendar_type_id=1 and edw_calendar_id=1001;
2909: l_start_date date;
2910: l_year number;
2911: l_qtr number;
2914: --
2915: Begin
2916: if g_debug then
2917: write_to_log_file_n('select to_date(start_month||''/''||start_day||''/''||current_year,''MM/DD/YYYY'') '||
2918: 'from bsc_sys_calendars_b where edw_calendar_type_id=1 and edw_calendar_id=1001');
2919: end if;
2920: open c1;
2921: fetch c1 into l_cal_start_date;
2922: close c1;
2976: End;
2977:
2978: procedure get_445_cal_start_date(p_mode varchar2) is
2979: --
2980: cursor c1 is select start_month||'/'||start_day||'/'||current_year from bsc_sys_calendars_b
2981: where edw_calendar_type_id=1 and edw_calendar_id=1002;
2982: --
2983: l_start_date date;
2984: l_year number;
2988: --
2989: Begin
2990: if g_debug then
2991: write_to_log_file_n('select to_date(start_month||''/''||start_day||''/''||current_year,''MM/DD/YYYY'') '||
2992: 'from bsc_sys_calendars_b where edw_calendar_type_id=1 and edw_calendar_id=1002');
2993: end if;
2994: open c1;
2995: fetch c1 into l_cal_start_date;
2996: close c1;
3041: End;
3042:
3043: procedure get_greg_cal_start_date(p_mode varchar2) is
3044: --
3045: cursor c1 is select start_month||'/'||start_day||'/'||current_year from bsc_sys_calendars_b
3046: where edw_calendar_type_id=1 and edw_calendar_id=1003;
3047: --
3048: l_start_date date;
3049: l_year number;
3053: --
3054: Begin
3055: if g_debug then
3056: write_to_log_file_n('select to_date(start_month||''/''||start_day||''/''||current_year,''MM/DD/YYYY'') '||
3057: 'from bsc_sys_calendars_b where edw_calendar_type_id=1 and edw_calendar_id=1003');
3058: end if;
3059: open c1;
3060: fetch c1 into l_cal_start_date;
3061: close c1;
3211: x_status := 1;
3212: END;
3213:
3214: function is_dbi_cal_metadata_loaded return boolean is
3215: cursor c1 is select 1 from bsc_sys_calendars_b where edw_calendar_type_id=1 and edw_calendar_id =1001;
3216: l_res number;
3217: Begin
3218: open c1;
3219: fetch c1 into l_res;
3271:
3272: --AW_INTEGRATION: New procedure
3273: procedure load_dbi_calendars_into_aw is
3274: --
3275: cursor c1 is select calendar_id from bsc_sys_calendars_b where edw_calendar_type_id = 1;
3276: l_calendar_id number;
3277: --
3278: l_dim varchar2(200);
3279: l_oo bsc_aw_md_wrapper.bsc_olap_object_tb;
3279: l_oo bsc_aw_md_wrapper.bsc_olap_object_tb;
3280: Begin
3281: if g_debug then
3282: write_to_log_file_n('In load_dbi_calendars_into_aw '||get_time);
3283: write_to_log_file_n('cursor c1 is select calendar_id from bsc_sys_calendars_b where edw_calendar_type_id = 1;'||get_time);
3284: end if;
3285: open c1;
3286: loop
3287: fetch c1 into l_calendar_id;