The following lines contain the word 'select', 'insert', 'update' or 'delete':
/*INSERT INTO bim_param_test values(p_page_parameter_tbl(i).parameter_name,
p_page_parameter_tbl(i).parameter_value,
p_page_parameter_tbl(i).parameter_id);*/
/*INSERT INTO bim_param_test values('get_bim_page_params success',
nvl(l_comp_type,'NULL'),nvl(l_period_type,'NULL'),
DBMS_UTILITY.get_time,l_country,NULL,null);
/*INSERT INTO bim_param_test values('get_bim_page_params excpetion',
nvl(l_comp_type,'NULL'),nvl(l_period_type,'NULL'),
DBMS_UTILITY.get_time,l_country,l_sql_errm,null);
SELECT resource_id
FROM JTF_RS_RESOURCE_EXTNS
WHERE user_id = FND_GLOBAL.user_id;
SELECT count(*)
FROM JTF_RS_RESOURCE_EXTNS r, bim_i_admin_group a
WHERE user_id = FND_GLOBAL.user_id
AND r.resource_id = a.resource_id;
'SELECT name VIEWBY, viewbyid,
fund_type BIM_ATTRIBUTE2,
fund_category BIM_ATTRIBUTE20,
original_budget BIM_ATTRIBUTE3,
pre_balance BIM_ATTRIBUTE4,
transfer_in BIM_ATTRIBUTE5,
transfer_out BIM_ATTRIBUTE6,
holdback BIM_ATTRIBUTE9,
accrual BIM_ATTRIBUTE7,
committed BIM_ATTRIBUTE8,
cur_balance BIM_ATTRIBUTE10,
planned BIM_ATTRIBUTE11,
utilized BIM_ATTRIBUTE12,
decode(viewbyid,null,NULL,'||''''||l_url_str||''''||' ) bim_url1,
sum(original_budget) over() BIM_GRAND_TOTAL1,
sum(pre_balance) over() BIM_GRAND_TOTAL2,
sum(transfer_in) over() BIM_GRAND_TOTAL3,
sum(transfer_out) over() BIM_GRAND_TOTAL4,
sum(holdback) over() BIM_GRAND_TOTAL7,
sum(accrual) over() BIM_GRAND_TOTAL5,
sum(committed) over() BIM_GRAND_TOTAL6,
sum(cur_balance) over() BIM_GRAND_TOTAL8,
sum(planned) over() BIM_GRAND_TOTAL9,
sum(utilized) over() BIM_GRAND_TOTAL10
FROM
(
SELECT
VIEWBYID,
e.short_name name,
l.meaning fund_type,
cat.category_name fund_category,
sum(original_budget) original_budget,
sum(pre_balance) pre_balance,
sum(transfer_in) transfer_in,
sum(transfer_out) transfer_out,
sum(holdback) holdback,
sum(accrual)accrual,
sum(committed) committed,
sum(cur_balance) cur_balance,
sum(planned) planned,
sum(utilized) utilized
FROM
( SELECT
decode(a.leaf_node_flag,''Y'',null,a.fund_id) VIEWBYID,
a.fund_id fund_id,
a.fund_type fund_type,
a.category_id category_id,
0 original_budget,
0 pre_balance,
sum(transfer_in'||l_curr_suffix||') transfer_in,
sum(transfer_out'||l_curr_suffix||') transfer_out,
sum(holdback'||l_curr_suffix||') holdback,
sum(accrual'||l_curr_suffix||')accrual,
sum(committed'||l_curr_suffix||') committed,
0 cur_balance,
0 planned,
sum(utilized'||l_curr_suffix||') utilized
FROM BIM_I_BGT_LVL_MV a,
fii_time_rpt_struct_v cal';
SELECT
decode(a.leaf_node_flag,''Y'',null,a.fund_id) VIEWBYID,
a.fund_id fund_id,
a.fund_type fund_type,
a.category_id category_id,
sum(decode(cal.report_date,&BIS_CURRENT_ASOF_DATE,a.original_budget'||l_curr_suffix||',0)) original_budget,
sum(decode(cal.report_date,&BIS_CURRENT_EFFECTIVE_START_DATE - 1,
a.original_budget'||l_curr_suffix||'+a.accrual'||l_curr_suffix||'+a.transfer_in'||l_curr_suffix||'-a.transfer_out'||l_curr_suffix||'-a.holdback'||l_curr_suffix||'-a.committed'||l_curr_suffix||',0)) pre_balance,
0 transfer_in,
0 transfer_out,
0 holdback,
0 accrual,
0 committed,
sum(decode(cal.report_date,&BIS_CURRENT_ASOF_DATE,
a.original_budget'||l_curr_suffix||'+a.accrual'||l_curr_suffix||'+a.transfer_in'||l_curr_suffix||'-a.transfer_out'||l_curr_suffix||'-a.holdback'||l_curr_suffix||'-a.committed'||l_curr_suffix||',0)) cur_balance,
sum(decode(cal.report_date,&BIS_CURRENT_ASOF_DATE,a.planned'||l_curr_suffix||'-a.committed'||l_curr_suffix||',0)) planned,
0 utilized
FROM BIM_I_BGT_LVL_MV a,
fii_time_rpt_struct_v cal
';
'SELECT name VIEWBY,
viewbyid,
fund_type BIM_ATTRIBUTE2,
fund_category BIM_ATTRIBUTE20,
original_budget BIM_ATTRIBUTE3,
pre_balance BIM_ATTRIBUTE4,
transfer_in BIM_ATTRIBUTE5,
transfer_out BIM_ATTRIBUTE6,
holdback BIM_ATTRIBUTE9,
accrual BIM_ATTRIBUTE7,
committed BIM_ATTRIBUTE8,
cur_balance BIM_ATTRIBUTE10,
planned BIM_ATTRIBUTE11,
utilized BIM_ATTRIBUTE12,
decode(viewbyid,null,NULL,'||''''||l_url_str||''''||' ) bim_url1,
sum(original_budget) over() BIM_GRAND_TOTAL1,
sum(pre_balance) over() BIM_GRAND_TOTAL2,
sum(transfer_in) over() BIM_GRAND_TOTAL3,
sum(transfer_out) over() BIM_GRAND_TOTAL4,
sum(holdback) over() BIM_GRAND_TOTAL7,
sum(accrual) over() BIM_GRAND_TOTAL5,
sum(committed) over() BIM_GRAND_TOTAL6,
sum(cur_balance) over() BIM_GRAND_TOTAL8,
sum(planned) over() BIM_GRAND_TOTAL9,
sum(utilized) over() BIM_GRAND_TOTAL10
FROM
(
SELECT
VIEWBYID,
e.short_name name,
l.meaning fund_type,
cat.category_name fund_category,
sum(original_budget) original_budget,
sum(pre_balance) pre_balance,
sum(transfer_in) transfer_in,
sum(transfer_out) transfer_out,
sum(holdback) holdback,
sum(accrual)accrual,
sum(committed) committed,
sum(cur_balance) cur_balance,
sum(planned) planned,
sum(utilized) utilized
FROM
( SELECT
decode(a.leaf_node_flag,''Y'',null,a.fund_id) VIEWBYID,
a.fund_id fund_id,
a.fund_type fund_type,
a.category_id category_id,
0 original_budget,
0 pre_balance,
sum(transfer_in'||l_curr_suffix||') transfer_in,
sum(transfer_out'||l_curr_suffix||') transfer_out,
sum(holdback'||l_curr_suffix||') holdback,
sum(accrual'||l_curr_suffix||')accrual,
sum(committed'||l_curr_suffix||') committed,
0 cur_balance,
0 planned,
sum(utilized'||l_curr_suffix||') utilized
FROM BIM_I_BGT_LVL_MV a,
fii_time_rpt_struct_v cal';
SELECT
decode(a.leaf_node_flag,''Y'',null,a.fund_id) VIEWBYID,
a.fund_id fund_id,
a.fund_type fund_type,
a.category_id category_id,
sum(decode(cal.report_date,&BIS_CURRENT_ASOF_DATE,a.original_budget'||l_curr_suffix||',0)) original_budget,
sum(decode(cal.report_date,&BIS_CURRENT_EFFECTIVE_START_DATE - 1,
a.original_budget'||l_curr_suffix||'+a.accrual'||l_curr_suffix||'+a.transfer_in'||l_curr_suffix||'
-a.transfer_out'||l_curr_suffix||'-a.holdback'||l_curr_suffix||'-a.committed'||l_curr_suffix||',0)) pre_balance,
0 transfer_in,
0 transfer_out,
0 holdback,
0 accrual,
0 committed,
sum(decode(cal.report_date,&BIS_CURRENT_ASOF_DATE,
a.original_budget'||l_curr_suffix||'+a.accrual'||l_curr_suffix||'+a.transfer_in'||l_curr_suffix||'-a.transfer_out'||l_curr_suffix||'
-a.holdback'||l_curr_suffix||'-a.committed'||l_curr_suffix||',0)) cur_balance,
sum(decode(cal.report_date,&BIS_CURRENT_ASOF_DATE,a.planned'||l_curr_suffix||'-a.committed'||l_curr_suffix||',0)) planned,
0 utilized
FROM BIM_I_BGT_LVL_MV a,
fii_time_rpt_struct_v cal';
'SELECT name VIEWBY,
VIEWBYID,
original_budget BIM_ATTRIBUTE3,
pre_balance BIM_ATTRIBUTE4,
transfer_in BIM_ATTRIBUTE5,
transfer_out BIM_ATTRIBUTE6,
holdback BIM_ATTRIBUTE9,
accrual BIM_ATTRIBUTE7,
committed BIM_ATTRIBUTE8,
cur_balance BIM_ATTRIBUTE10,
planned BIM_ATTRIBUTE11,
utilized BIM_ATTRIBUTE12,
decode(viewbyid,null,NULL,'||''''||l_url_str||''''||' ) bim_url1,
sum(original_budget) over() BIM_GRAND_TOTAL1,
sum(pre_balance) over() BIM_GRAND_TOTAL2,
sum(transfer_in) over() BIM_GRAND_TOTAL3,
sum(transfer_out) over() BIM_GRAND_TOTAL4,
sum(holdback) over() BIM_GRAND_TOTAL7,
sum(accrual) over() BIM_GRAND_TOTAL5,
sum(committed) over() BIM_GRAND_TOTAL6,
sum(cur_balance) over() BIM_GRAND_TOTAL8,
sum(planned) over() BIM_GRAND_TOTAL9,
sum(utilized) over() BIM_GRAND_TOTAL10
FROM
(
SELECT
VIEWBYID,
e.category_name name,
sum(original_budget) original_budget,
sum(pre_balance) pre_balance,
sum(transfer_in) transfer_in,
sum(transfer_out) transfer_out,
sum(holdback) holdback,
sum(accrual)accrual,
sum(committed) committed,
sum(cur_balance) cur_balance,
sum(planned) planned,
sum(utilized) utilized
FROM
( SELECT
decode(a.leaf_node_flag,''Y'',null,a.category_id) VIEWBYID,
a.category_id category_id,
0 original_budget,
0 pre_balance,
sum(transfer_in'||l_curr_suffix||') transfer_in,
sum(transfer_out'||l_curr_suffix||') transfer_out,
sum(holdback'||l_curr_suffix||') holdback,
sum(accrual'||l_curr_suffix||')accrual,
sum(committed'||l_curr_suffix||') committed,
0 cur_balance,
0 planned,
sum(utilized) utilized
FROM BIM_I_BGT_CAT_MV a,
fii_time_rpt_struct_v cal';
SELECT
decode(a.leaf_node_flag,''Y'',null,a.category_id) VIEWBYID,
a.category_id category_id,
sum(decode(cal.report_date,&BIS_CURRENT_ASOF_DATE,a.original_budget'||l_curr_suffix||',0)) original_budget,
sum(decode(cal.report_date,&BIS_CURRENT_EFFECTIVE_START_DATE - 1,
a.original_budget'||l_curr_suffix||'+a.accrual'||l_curr_suffix||'+a.transfer_in'||l_curr_suffix||'
-a.transfer_out'||l_curr_suffix||'-a.holdback'||l_curr_suffix||'-a.committed'||l_curr_suffix||',0)) pre_balance,
0 transfer_in,
0 transfer_out,
0 holdback,
0 accrual,
0 committed,
sum(decode(cal.report_date,&BIS_CURRENT_ASOF_DATE,a.original_budget'||l_curr_suffix||'
+a.accrual'||l_curr_suffix||'+a.transfer_in'||l_curr_suffix||'-a.transfer_out'||l_curr_suffix||'-a.holdback'||l_curr_suffix||'-a.committed'||l_curr_suffix||',0)) cur_balance,
sum(decode(cal.report_date,&BIS_CURRENT_ASOF_DATE,a.planned'||l_curr_suffix||'-a.committed'||l_curr_suffix||',0)) planned,
0 utilized
FROM BIM_I_BGT_CAT_MV a,
fii_time_rpt_struct_v cal';
'SELECT name VIEWBY,
VIEWBYID,
original_budget BIM_ATTRIBUTE3,
pre_balance BIM_ATTRIBUTE4,
transfer_in BIM_ATTRIBUTE5,
transfer_out BIM_ATTRIBUTE6,
holdback BIM_ATTRIBUTE9,
accrual BIM_ATTRIBUTE7,
committed BIM_ATTRIBUTE8,
cur_balance BIM_ATTRIBUTE10,
planned BIM_ATTRIBUTE11,
utilized BIM_ATTRIBUTE12,
decode(viewbyid,null,NULL,'||''''||l_url_str||''''||' ) bim_url1,
sum(original_budget) over() BIM_GRAND_TOTAL1,
sum(pre_balance) over() BIM_GRAND_TOTAL2,
sum(transfer_in) over() BIM_GRAND_TOTAL3,
sum(transfer_out) over() BIM_GRAND_TOTAL4,
sum(holdback) over() BIM_GRAND_TOTAL7,
sum(accrual) over() BIM_GRAND_TOTAL5,
sum(committed) over() BIM_GRAND_TOTAL6,
sum(cur_balance) over() BIM_GRAND_TOTAL8,
sum(planned) over() BIM_GRAND_TOTAL9,
sum(utilized) over() BIM_GRAND_TOTAL10
FROM
(
SELECT
VIEWBYID,
e.category_name name,
sum(original_budget) original_budget,
sum(pre_balance) pre_balance,
sum(transfer_in) transfer_in,
sum(transfer_out) transfer_out,
sum(holdback) holdback,
sum(accrual)accrual,
sum(committed) committed,
sum(cur_balance) cur_balance,
sum(planned) planned,
sum(utilized) utilized
FROM
( SELECT
decode(a.leaf_node_flag,''Y'',null,a.category_id) VIEWBYID,
a.category_id category_id,
0 original_budget,
0 pre_balance,
sum(transfer_in'||l_curr_suffix||') transfer_in,
sum(transfer_out'||l_curr_suffix||') transfer_out,
sum(holdback'||l_curr_suffix||') holdback,
sum(accrual'||l_curr_suffix||')accrual,
sum(committed'||l_curr_suffix||') committed,
0 cur_balance,
0 planned,
sum(utilized'||l_curr_suffix||') utilized
FROM BIM_I_BGT_CAT_MV a,
fii_time_rpt_struct_v cal';
SELECT
decode(a.leaf_node_flag,''Y'',null,a.category_id) VIEWBYID,
a.category_id category_id,
sum(decode(cal.report_date,&BIS_CURRENT_ASOF_DATE,a.original_budget'||l_curr_suffix||',0)) original_budget,
sum(decode(cal.report_date,&BIS_CURRENT_EFFECTIVE_START_DATE - 1,a.original_budget'||l_curr_suffix||'
+a.accrual'||l_curr_suffix||'+a.transfer_in'||l_curr_suffix||'-a.transfer_out'||l_curr_suffix||'
-a.holdback'||l_curr_suffix||'-a.committed'||l_curr_suffix||',0)) pre_balance,
0 transfer_in,
0 transfer_out,
0 holdback,
0 accrual,
0 committed,
sum(decode(cal.report_date,&BIS_CURRENT_ASOF_DATE,a.original_budget'||l_curr_suffix||'+a.accrual'||l_curr_suffix||'
+a.transfer_in'||l_curr_suffix||'-a.transfer_out'||l_curr_suffix||'-a.holdback'||l_curr_suffix||'-a.committed'||l_curr_suffix||',0)) cur_balance,
sum(decode(cal.report_date,&BIS_CURRENT_ASOF_DATE,a.planned'||l_curr_suffix||'-a.committed'||l_curr_suffix||',0)) planned,
0 utilized
FROM BIM_I_BGT_CAT_MV a,
fii_time_rpt_struct_v cal';
l_select_clause varchar2(1000);
l_select VARCHAR2 (20000); -- to build inner select to pick data from mviews
l_pc_select VARCHAR2 (20000); -- to build inner select to pick data directly assigned to the product category hirerachy
l_select_cal VARCHAR2 (20000); -- to build select calculation part
l_select_filter VARCHAR2 (20000); -- to build select filter part
/* variables to hold columns names in l_select clauses */
l_col VARCHAR2(1000);
select object_type
from bim_i_source_codes
where source_code_id=replace(l_campaign_id,'''');
l_url_str_csch :='pFunctionName=AMS_WB_CSCH_UPDATE&omomode=UPDATE&MidTab=TargetAccDSCRN&searchType=customize&OA_SubTabIdx=3&retainAM=Y&addBreadCrumb=S&addBreadCrumb=Y&objId=';
/** to add meaning in select clause only in case of campaign view by */
IF (l_view_by = 'CAMPAIGN+CAMPAIGN') THEN
l_meaning:=' meaning,object_id,object_type,usage ';
/* l_select_cal is common part of select statement for all view by to calculate grand totals and change */
l_select_cal :='
SELECT '||
l_view_disp ||'
viewbyid,
bim_attribute2,
bim_attribute3,
bim_attribute4,
bim_attribute5,
bim_attribute6,
bim_attribute8,
bim_attribute7,'||l_url||'
bim_grand_total1,
bim_grand_total2,
bim_grand_total3,
bim_grand_total4,
bim_grand_total5
FROM
(
SELECT name VIEWBY,object_id,object_type,usage,
meaning BIM_ATTRIBUTE2,
approved BIM_ATTRIBUTE3,
utilized BIM_ATTRIBUTE4,
total_approved BIM_ATTRIBUTE5,
total_utilized BIM_ATTRIBUTE6,
total_approved BIM_ATTRIBUTE8,
balance BIM_ATTRIBUTE7,
sum(approved) over() BIM_GRAND_TOTAL1,
sum(utilized) over() BIM_GRAND_TOTAL2,
sum(total_approved) over() BIM_GRAND_TOTAL3,
sum(total_utilized) over() BIM_GRAND_TOTAL4,
sum(balance) over() BIM_GRAND_TOTAL5,
VIEWBYID
FROM
(
SELECT
viewbyid,
name,'||
l_meaning||
',sum(approved) approved,
sum(utilized) utilized,
sum(total_approved) total_approved,
sum(total_utilized) total_utilized,
sum(total_approved)-sum(total_utilized) balance
FROM
( ';
/* l_from contains time dimension table common to all select statement for all view by */
l_from :=',fii_time_rpt_struct_v cal ';
/* l_where contains where clause to join time dimension table common to all select statement for all view by */
l_where :=' WHERE a.time_id = cal.time_id
AND a.period_type_id = cal.period_type_id
AND cal.calendar_id= -1
';
/* l_select_filter contains group by and filter clause to remove uneccessary records with zero values */
l_select_filter := ' ) GROUP BY viewbyid,name '||l_filtercol||
')
)
WHERE
bim_attribute3 <> 0
or bim_attribute4 <> 0
or bim_attribute5 <> 0
or bim_attribute6 <> 0
or bim_attribute7 <> 0
or bim_attribute8 <> 0
&ORDER_BY_CLAUSE ';
/*appending l_select_cal for calculation and sql clause to pick data and filter clause to filter records with zero values***/
l_sqltext:= l_select_cal||
/******** inner select start from here */
/* select to get camapigns and programs */
' SELECT
a.source_code_id VIEWBYID,
name.name name,
name.object_type_mean meaning '||
l_comm_col1 ||
l_from ||l_where||l_where1||l_top_cond||
' AND cal.report_date=&BIS_CURRENT_ASOF_DATE
and name.language=USERENV(''LANG'')'
||l_groupby|| ',name.name'||
' UNION ALL
SELECT
a.source_code_id VIEWBYID,
name.name name,
name.object_type_mean meaning '||
l_comm_col2 ||
l_from ||l_where||
l_where2 ||l_top_cond||
' AND cal.report_date=&BIS_CURRENT_ASOF_DATE
and name.language=USERENV(''LANG'')'
|| l_groupby|| ',name.name '||
l_select_filter /* appending filter clause */
;
/* source_code_id is passed from the page, object selected from the page to be drill may be program,campaign,event,one off event*****/
/* appending table in l_form and joining conditon for the bim_i_source_codes */
l_where :=l_where ||' AND a.immediate_parent_id = :l_campaign_id ';
l_sqltext:= l_select_cal||
' SELECT
a.source_code_id VIEWBYID,
name.name name,
name.object_type_mean meaning '||
l_comm_col1 ||
l_from ||l_table_bud||l_where||l_where1||l_where_bud||
' AND cal.report_date=&BIS_CURRENT_ASOF_DATE
and name.language=USERENV(''LANG'')'||
l_groupby||
' ,name.name'||
' UNION ALL
SELECT
a.source_code_id VIEWBYID,
name.name name,
name.object_type_mean meaning '||
l_comm_col2 ||
l_from ||l_table_bud||l_where||l_where2||l_where_bud||
' AND cal.report_date=&BIS_CURRENT_ASOF_DATE
and name.language=USERENV(''LANG'')'||
l_groupby||
' ,name.name'||
l_select_filter ;
,( SELECT e.parent_id parent_id ,e.value value
FROM eni_item_vbh_nodes_v e
WHERE e.top_node_flag=''Y''
AND e.child_id = e.parent_id) p ';
l_col:=' SELECT
p.value name,
p.parent_id viewbyid,
null meaning ';
/** reassigning value to l_pc_from and l_pc_where for product category hirerachy drill down for values directly assigned to prodcut select from the page*/
l_pc_from:= l_from||
',(select e.id id,e.value value
from eni_item_vbh_nodes_v e
where e.parent_id = :l_cat_id
AND e.parent_id = e.child_id
AND leaf_node_flag <> ''Y''
) p ';
,(select e.id,e.value,leaf_node_flag
from eni_item_vbh_nodes_v e
where
e.parent_id =:l_cat_id
AND e.id = e.child_id
AND((e.leaf_node_flag=''N'' AND e.parent_id<>e.id) OR e.leaf_node_flag=''Y'')
) p ';
l_col:=' SELECT
p.value name,
decode(p.leaf_node_flag,''Y'',-777,p.id) viewbyid,
null meaning ';
/* building l_pc_select to get values directly assigned to product category passed from the page */
IF l_cat_id is not null THEN
l_pc_col:=' SELECT
p.value name,
-999 viewbyid,
null meaning ';
l_pc_select :=
' UNION ALL ' ||
l_pc_col||
l_comm_col1||
l_pc_from||
l_pc_where ||l_where1||' AND cal.report_date =&BIS_CURRENT_ASOF_DATE'||
l_pc_groupby ||
' UNION ALL ' ||
l_pc_col||
l_comm_col2||
l_pc_from||
l_pc_where ||l_where2||' AND cal.report_date =&BIS_CURRENT_ASOF_DATE'||
l_pc_groupby
;
l_col:=' SELECT
decode(d.name,null,bim_pmv_dbi_utl_pkg.get_lookup_value('||''''||'UNA'||''''||')'||',d.name) name,
a.object_country viewbyid,
null meaning ';
l_col:=' SELECT
decode(d.value,null,bim_pmv_dbi_utl_pkg.get_lookup_value('||''''||'UNA'||''''||')'||',d.value) name,
null viewbyid,
null meaning ';
l_col:=' SELECT
decode(d.value,null,bim_pmv_dbi_utl_pkg.get_lookup_value('||''''||'UNA'||''''||')'||',d.value) name,
null viewbyid,
null meaning ';
l_select := l_col||
l_comm_col1||
l_from||
l_where ||l_where1||' AND cal.report_date =&BIS_CURRENT_ASOF_DATE '||
l_groupby ||
' UNION ALL'||
l_col||
l_comm_col2||
l_from||
l_where ||l_where2||' AND cal.report_date =&BIS_CURRENT_ASOF_DATE '||
l_groupby ||
l_pc_select /* l_pc_select only applicable when product category is not all and view by is product category */
;
l_sqltext:= l_select_cal||
l_select||
l_select_filter;