The following lines contain the word 'select', 'insert', 'update' or 'delete':
g_periodicities.delete;
g_dimensions.delete;
g_measures.delete;
select calendar_id, custom_code, db_column_name from bsc_sys_periodicities
where periodicity_id=p_periodicity_id
-- ignore these type of periodicities, they are std periodicites but dont have a db_column_name
and periodicity_type not in (11,12);
l_stmt := 'INSERT into '||g_keys_table||'(
SESSION_ID,
REPORT_DATE,
XTD_PERIOD,
XTD_YEAR,
XTD_PERIODICITY,
PERIOD,
YEAR,
PERIOD_TYPE_ID,
PERIODICITY_ID,
PERIOD_FLAG,
DAY_COUNT,
ROLLING_FLAG,
LAST_UPDATE_DATE)
select
:1,
null,
null,
null,
null, '||
l_db_column_name||
', year,
null,
:2,
null,
null,
:3,
sysdate
from bsc_db_calendar
where year between :4 and :5
and '||l_db_column_name||' between :6 and :7
and calendar_id = :8';
l_stmt := 'INSERT into '||g_keys_table||'(
SESSION_ID,
REPORT_DATE,
XTD_PERIOD,
XTD_YEAR,
XTD_PERIODICITY,
PERIOD,
YEAR,
PERIOD_TYPE_ID,
PERIODICITY_ID,
PERIOD_FLAG,
DAY_COUNT,
ROLLING_FLAG,
LAST_UPDATE_DATE)
select
:1,
null,
period_id,
year,
:2,
period_id,
year,
null,
:3,
0,
null,
:4,
sysdate
from bsc_sys_periods
where
year between :5 and :6
and period_id between :7 and :8
and periodicity_id = :9';
execute immediate 'update '||g_keys_table||' set period_flag=1 where period = (select max(period) from '||g_keys_table||' group by periodicity_id)';
select count(1) into l_count from bsc_sys_measures where short_name=p_measure;