The following lines contain the word 'select', 'insert', 'update' or 'delete':
g_select VARCHAR2(1000);
g_select := get_prob_avoid_rpt_select;
g_query := g_select || g_table || g_where;
-- update the total percentage column
g_query := 'UPDATE biv_tmp_hs1
SET col12 =
round((100*col12/(select sum(col10)
from biv_tmp_hs1 b
where b.report_code = ''BIV_HS_PROB_AVOID''
and b.session_id =
biv_core_pkg.get_session_id
)),2)
WHERE report_code = ''BIV_HS_PROB_AVOID'' and
session_id = :session_id ';
UPDATE biv_tmp_hs1
set col6 = (select description from mtl_system_items_vl
where inventory_item_id = to_number(col6) and rownum = 1)
WHERE report_code = ''BIV_HS_PROB_AVOID'' and
session_id = :session_id and
col6 is not null ' using biv_core_pkg.get_session_id;
UPDATE biv_tmp_hs1
set col8 = (select description from mtl_system_items_vl
where inventory_item_id = to_number(col8) and rownum = 1),
col14 = 1
WHERE report_code = ''BIV_HS_PROB_AVOID'' and
session_id = :session_id and
col8 is not null ' using biv_core_pkg.get_session_id;
update biv_tmp_hs1
set col9 = l_param_for_drill || 'P_PRD_ID' ||
biv_core_pkg.g_value_sep || nvl(col2,biv_core_pkg.g_null) ||
biv_core_pkg.g_param_sep || 'P_COMP_ID' ||
biv_core_pkg.g_value_sep || nvl(col5,biv_core_pkg.g_null) ||
biv_core_pkg.g_param_sep || 'P_SUBCOMP_ID' ||
biv_core_pkg.g_value_sep || nvl(col7,biv_core_pkg.g_null) ||
biv_core_pkg.g_param_sep
where session_id = g_session_id
and report_code = 'BIV_HS_PROB_AVOID';
select count(*) into l_ttl_recs
from biv_tmp_hs1
WHERE report_code = 'BIV_HS_PROB_AVOID' and
session_id = biv_core_pkg.get_session_id;
biv_core_pkg.biv_debug('Inserting Total Row','BIV_HS_PROB_AVOID');
insert into biv_tmp_hs1(report_code, session_id, rowno, col2, col10,
col14, col9)
select 'BIV_HS_PROB_AVOID', l_session_id, max(rowno)+1,
l_ttl_meaning,sum(col10),2, l_param_for_drill
from biv_tmp_hs1
where report_code = 'BIV_HS_PROB_AVOID'
and session_id = l_session_id;
-- get select
FUNCTION get_prob_avoid_rpt_select RETURN VARCHAR2 IS
l_select_stmt varchar2(1000);
l_select_stmt := 'INSERT INTO biv_tmp_hs1 (report_code, session_id,col2, ';
l_select_stmt := l_select_stmt || 'col4,col6,col8,col10,col12,col5,col7) ';
l_select_stmt := l_select_stmt || 'SELECT :g_report_code, :session_id,';
l_select_stmt := l_select_stmt || 'sr.inventory_item_id prod_id, ';
l_select_stmt := l_select_stmt || 'substr(nvl(inv1.description,''' || l_na_desc || '''),1,50) product, ';
l_select_stmt := l_select_stmt || 'sr.inv_component_id component, ';
l_select_stmt := l_select_stmt || 'sr.inv_subcomponent_id subcomponent, ';
l_select_stmt := l_select_stmt || '
count(distinct sr.incident_id),
count(distinct sr.incident_id),
sr.inv_component_id, sr.inv_subcomponent_id ';
return l_select_stmt;
END get_prob_avoid_rpt_select;
g_select := get_prob_avoid_res_rpt_select;
g_query := g_select || g_table || g_where;
-- update the total percentage column
g_query := 'UPDATE biv_tmp_hs1
SET col4 =
round((100*col4/(select sum(b.col2)
from biv_tmp_hs1 b
where b.report_code = ''BIV_HS_PROB_AVOID_RES''
and b.session_id =
biv_core_pkg.get_session_id
)),2)
WHERE report_code = ''BIV_HS_PROB_AVOID_RES'' and
session_id = :session_id ';
update biv_tmp_hs1
set col1 = l_new_param_str || 'P_RESL_CODE' ||
biv_core_pkg.g_value_sep ||
nvl(col5,biv_core_pkg.g_null) ||
biv_core_pkg.g_param_sep
where report_code = 'BIV_HS_PROB_AVOID_RES'
and session_id = g_session_id;
-- get select
FUNCTION get_prob_avoid_res_rpt_select RETURN VARCHAR2 IS
l_select_stmt varchar2(1000);
l_select_stmt := 'INSERT INTO biv_tmp_hs1 (report_code,session_id,col2, ';
l_select_stmt := l_select_stmt || 'col4,col5,col6) ';
l_select_stmt := l_select_stmt || 'SELECT :report_code,:session_id, ';
l_select_stmt := l_select_stmt || '
count(sr.incident_id),
count(sr.incident_id),sr.resolution_code,clr.meaning ';
return l_select_stmt;
END get_prob_avoid_res_rpt_select;