The following lines contain the word 'select', 'insert', 'update' or 'delete':
(SELECT 1
FROM org_access o
WHERE o.responsibility_id = fnd_global.resp_id
AND o.resp_application_id = fnd_global.resp_appl_id
AND o.organization_id = fact.inv_org_id)
OR EXISTS
(SELECT 1
FROM mtl_parameters org
WHERE org.organization_id = fact.inv_org_id
AND NOT EXISTS
(SELECT 1
FROM org_access ora
WHERE org.organization_id = ora.organization_id)))';
l_stmt := 'SELECT fii1.start_date VIEWBY, fii1.start_date ISC_ATTRIBUTE_2, '
|| l_att_2 || ' ISC_ATTRIBUTE_3, nvl(s.curr_book_to_ship_days,0) ISC_MEASURE_1,
nvl(s.curr_shipped_line_cnt,0) ISC_MEASURE_2,
nvl(s.prev_book_to_ship_days,0) /
decode(nvl(s.prev_shipped_line_cnt,0), 0, NULL,
abs(nvl(s.prev_shipped_line_cnt,0))) ISC_MEASURE_5,
nvl(s.prev_book_to_ship_days,0) ISC_MEASURE_3,
nvl(s.prev_shipped_line_cnt,0) ISC_MEASURE_4,
nvl(s.curr_book_to_ship_days,0) /
decode(nvl(s.curr_shipped_line_cnt,0), 0, NULL,
abs(nvl(s.curr_shipped_line_cnt,0))) ISC_MEASURE_6,
nvl(s.curr_book_to_ship_days,0) /
decode(nvl(s.curr_shipped_line_cnt,0), 0, NULL,
abs(nvl(s.curr_shipped_line_cnt,0))) -
nvl(s.prev_book_to_ship_days,0) /
decode(nvl(s.prev_shipped_line_cnt,0), 0, NULL,
abs(nvl(s.prev_shipped_line_cnt,0))) ISC_MEASURE_7,
null CURRENCY, -- obsolete
null ISC_CALC_ITEM_2, -- obsolete
null ISC_CALC_ITEM_1, -- obsolete
null ISC_CALC_ITEM_3 -- obsolete
FROM (SELECT dates.start_date START_DATE,
sum(decode(dates.period, ''C'',
nvl(fact.book_to_ship_days,0), 0)) CURR_BOOK_TO_SHIP_DAYS,
sum(decode(dates.period, ''P'',
nvl(fact.book_to_ship_days,0), 0)) PREV_BOOK_TO_SHIP_DAYS,
sum(decode(dates.period, ''C'',
nvl(fact.shipped_line_cnt,0), 0)) CURR_SHIPPED_LINE_CNT,
sum(decode(dates.period, ''P'',
nvl(fact.shipped_line_cnt,0), 0)) PREV_SHIPPED_LINE_CNT
FROM (SELECT fii1.start_date START_DATE,
''C'' PERIOD,
least(fii1.end_date, &BIS_CURRENT_ASOF_DATE) REPORT_DATE
FROM '||l_period_type||' fii1
WHERE fii1.start_date BETWEEN &BIS_CURRENT_REPORT_START_DATE
AND &BIS_CURRENT_ASOF_DATE
UNION ALL
SELECT p2.start_date START_DATE,
''P'' PERIOD,
p1.report_date REPORT_DATE
FROM (SELECT least(fii1.end_date, &BIS_PREVIOUS_ASOF_DATE) REPORT_DATE,
rownum ID
FROM '||l_period_type||' fii1
WHERE fii1.start_date BETWEEN &BIS_PREVIOUS_REPORT_START_DATE
AND &BIS_PREVIOUS_ASOF_DATE
ORDER BY fii1.start_date DESC) p1,
(SELECT fii1.start_date START_DATE,
rownum ID
FROM '||l_period_type||' fii1
WHERE fii1.start_date BETWEEN &BIS_CURRENT_REPORT_START_DATE
AND &BIS_CURRENT_ASOF_DATE
ORDER BY fii1.start_date DESC) p2
WHERE p1.id(+) = p2.id) dates,
ISC_DBI_FM_0000_MV fact
WHERE fact.agg_level = :ISC_AGG_LEVEL
AND fact.time_id = to_char(dates.report_date,''j'')
AND fact.period_type_id = 1 '
||l_inv_org_where
||l_inv_cat_where
||l_item_where
||l_customer_where||'
GROUP BY dates.start_date) s,
'||l_period_type||' fii1
WHERE fii1.start_date BETWEEN &BIS_CURRENT_REPORT_START_DATE
AND &BIS_CURRENT_ASOF_DATE
AND fii1.start_date = s.start_date(+)
ORDER BY fii1.start_date';
l_stmt := 'SELECT fii1.NAME VIEWBY, fii1.NAME ISC_ATTRIBUTE_2, '
|| l_att_2 || ' ISC_ATTRIBUTE_3, nvl(s.curr_book_to_ship_days,0) ISC_MEASURE_1,
nvl(s.curr_shipped_line_cnt,0) ISC_MEASURE_2,
nvl(s.prev_book_to_ship_days,0) /
decode(nvl(s.prev_shipped_line_cnt,0), 0, NULL,
abs(nvl(s.prev_shipped_line_cnt,0))) ISC_MEASURE_5,
nvl(s.prev_book_to_ship_days,0) ISC_MEASURE_3,
nvl(s.prev_shipped_line_cnt,0) ISC_MEASURE_4,
nvl(s.curr_book_to_ship_days,0) /
decode(nvl(s.curr_shipped_line_cnt,0), 0, NULL,
abs(nvl(s.curr_shipped_line_cnt,0))) ISC_MEASURE_6,
nvl(s.curr_book_to_ship_days,0) /
decode(nvl(s.curr_shipped_line_cnt,0), 0, NULL,
abs(nvl(s.curr_shipped_line_cnt,0))) -
nvl(s.prev_book_to_ship_days,0) /
decode(nvl(s.prev_shipped_line_cnt,0), 0, NULL,
abs(nvl(s.prev_shipped_line_cnt,0))) ISC_MEASURE_7,
null CURRENCY, -- obsolete
null ISC_CALC_ITEM_2, -- obsolete
null ISC_CALC_ITEM_1, -- obsolete
null ISC_CALC_ITEM_3 -- obsolete
FROM (SELECT dates.start_date START_DATE,
sum(decode(dates.period, ''C'',
nvl(fact.book_to_ship_days,0), 0)) CURR_BOOK_TO_SHIP_DAYS,
sum(decode(dates.period, ''P'',
nvl(fact.book_to_ship_days,0), 0)) PREV_BOOK_TO_SHIP_DAYS,
sum(decode(dates.period, ''C'',
nvl(fact.shipped_line_cnt,0), 0)) CURR_SHIPPED_LINE_CNT,
sum(decode(dates.period, ''P'',
nvl(fact.shipped_line_cnt,0), 0)) PREV_SHIPPED_LINE_CNT
FROM (SELECT fii1.start_date START_DATE,
''C'' PERIOD,
least(fii1.end_date, &BIS_CURRENT_ASOF_DATE) REPORT_DATE
FROM '||l_period_type||' fii1
WHERE fii1.start_date BETWEEN &BIS_CURRENT_REPORT_START_DATE
AND &BIS_CURRENT_ASOF_DATE
UNION ALL
SELECT p2.start_date START_DATE,
''P'' PERIOD,
p1.report_date REPORT_DATE
FROM (SELECT least(fii1.end_date, &BIS_PREVIOUS_ASOF_DATE) REPORT_DATE,
rownum ID
FROM '||l_period_type||' fii1
WHERE fii1.start_date BETWEEN &BIS_PREVIOUS_REPORT_START_DATE
AND &BIS_PREVIOUS_ASOF_DATE
ORDER BY fii1.start_date DESC) p1,
(SELECT fii1.start_date START_DATE,
rownum ID
FROM '||l_period_type||' fii1
WHERE fii1.start_date BETWEEN &BIS_CURRENT_REPORT_START_DATE
AND &BIS_CURRENT_ASOF_DATE
ORDER BY fii1.start_date DESC) p2
WHERE p1.id(+) = p2.id) dates,
ISC_DBI_FM_0000_MV fact,
FII_TIME_RPT_STRUCT_V cal
WHERE cal.report_date = dates.report_date
AND bitand(cal.record_type_id, &BIS_NESTED_PATTERN) = cal.record_type_id
AND fact.time_id = cal.time_id
AND fact.period_type_id = cal.period_type_id
AND fact.agg_level = :ISC_AGG_LEVEL'
||l_inv_org_where
||l_inv_cat_where
||l_item_where
||l_customer_where||'
GROUP BY dates.start_date) s,
'||l_period_type||' fii1
WHERE fii1.start_date BETWEEN &BIS_CURRENT_REPORT_START_DATE
AND &BIS_CURRENT_ASOF_DATE
AND fii1.start_date = s.start_date(+)
ORDER BY fii1.start_date';