The following lines contain the word 'select', 'insert', 'update' or 'delete':
l_query := '(select '
|| l_group_and_sel_clause
|| l_col_names
|| fnd_global.newline||' from '
|| p_fact_name
|| ' fact'
|| l_join_tables
|| l_full_where_clause
|| l_grpid_clause
|| fnd_global.newline||' group by '
|| l_group_and_sel_clause
|| l_paren_str;
if(i=1) then /*outer select clause needs to be built only once */
l_union_sel := l_union_sel
|| ', sum('
|| l_col_list(j)
|| ') '
|| l_col_list(j)
|| fnd_global.newline;
poa_dbi_util_pkg.get_rolling_inline_view || ' select' || fnd_global.newline
else ' ( select' || fnd_global.newline end
---End Changes for spend trend graph
|| l_union_sel
|| 'from (' || fnd_global.newline;
|| '(select' || fnd_global.newline
|| l_query_tbl(m).in_union_sel
|| 'from ' || fnd_global.newline
|| replace(l_query_tbl(m).template_sql,'order by cal.start_date','')
|| fnd_global.newline;
l_query := 'select '
|| l_sel_clause
|| fnd_global.newline
|| l_out_union_sel
|| 'from (' || fnd_global.newline;
l_query := l_query || 'select '
|| l_sel_clause || fnd_global.newline
|| l_query_tbl(m).in_union_sel
|| 'from ' || fnd_global.newline
|| '(('
|| l_query_tbl(m).template_sql;
'(select n.start_date'
|| case when p_xtd like 'RL%' then ', n.ordinal ' end
|| '
' ||l_col_names || '
from (select ' || p_fact_hint || ' '
|| case when p_xtd like 'RL%' then 'n.ordinal, ' end
|| 'n.start_date, n.report_date '
|| l_inner_col_names
|| ' from '
|| p_fact_name
|| ' fact,
'
|| case
when p_xtd like 'RL%' then
case
when (BITAND (l_inlist_bmap
, g_inlist_bal) = g_inlist_bal) then
'( select /*+ NO_MERGE */ cal.ordinal,cal.start_date, cal.report_date'
|| ' from ' || poa_dbi_util_pkg.get_calendar_table(p_xtd,'Y',l_compute_opening_bal,p_called_by_union => p_called_by_union )
|| ' cal
where '
|| l_time_clause
|| l_cal_clause
|| ' ) n
where fact.report_date = least(n.report_date,&LAST_COLLECTION)
'
ELSE
'( select /*+ NO_MERGE */ cal.ordinal,n.time_id,n.record_type_id,n.period_type_id,n.report_date,cal.start_date,cal.end_date'
|| ' from ' || poa_dbi_util_pkg.get_calendar_table(p_xtd, p_called_by_union => p_called_by_union)
|| ' cal, fii_time_structures n
where '
|| l_time_clause
|| l_cal_clause
-- &RLX_NESTED_PATTERN should be replaced with
-- some &BIS bind substitution when available from fii/bis team.
|| ' and bitand(n.record_type_id,&RLX_NESTED_PATTERN) = &RLX_NESTED_PATTERN ) n'
|| l_in_join_tables
|| '
where fact.time_id = n.time_id
and fact.period_type_id = n.period_type_id
'
end
else -- non RL%
' (select /*+ NO_MERGE */ n.time_id,n.record_type_id, n.period_type_id,n.report_date,cal.start_date,cal.end_date
from '
|| poa_dbi_util_pkg.get_calendar_table (p_xtd, p_called_by_union => p_called_by_union)
|| ' cal, fii_time_rpt_struct_v n
where '
|| l_time_clause
|| l_cal_clause
|| ' and bitand(n.record_type_id, '
|| CASE -- if one or more columns = YTD then use nested pattern
WHEN BITAND (l_inlist_bmap, g_inlist_ytd) = g_inlist_ytd
THEN '&YTD_NESTED_PATTERN'
ELSE '&BIS_NESTED_PATTERN'
END
|| ') = n.record_type_id ) n
' || l_in_join_tables || '
where fact.time_id = n.time_id
'
end
|| l_grpid_clause || '
' || p_where_clause || '
group by '
|| case when p_xtd like 'RL%' then 'n.ordinal, ' end
|| ' n.start_date, n.report_date) i, '
|| poa_dbi_util_pkg.get_calendar_table(p_xtd,'Y',l_compute_opening_bal, p_called_by_union => p_called_by_union )
|| ' n where i.start_date (+) = n.start_date '
|| l_outer_time_clause
|| case when p_xtd like 'RL%' then 'and i.ordinal(+) = n.ordinal ' end
|| '
group by '
|| case when p_xtd like 'RL%' then 'n.ordinal, ' end
|| 'n.start_date) iset, '
|| poa_dbi_util_pkg.get_calendar_table (p_xtd,'N','N', p_called_by_union => p_called_by_union )
|| ' cal '
|| '
where cal.start_date between '
|| case
when p_xtd like 'RL%' then
poa_dbi_util_pkg.get_report_start_date(p_xtd)
else
'&BIS_CURRENT_REPORT_START_DATE'
end
|| ' and &BIS_CURRENT_ASOF_DATE
and cal.start_date = iset.start_date(+)'
|| case when p_xtd like 'RL%' then ' and cal.ordinal = iset.ordinal(+)' end
|| '
order by cal.start_date';
select fnd_profile.value('VO_MAX_FETCH_SIZE')
into l_vo_max_fetch_size
from dual;