The following lines contain the word 'select', 'insert', 'update' or 'delete':
/* SELECT clause */
p_select_time VARCHAR2(1000) := 'to_char(NULL) ';
p_select_period_setname VARCHAR2(1000) := 'to_char(NULL) ';
p_select_org VARCHAR2(1000) := 'to_char(NULL) ';
p_select_geo VARCHAR2(1000) := 'to_char(NULL) ';
p_select_product VARCHAR2(1000) := 'to_char(NULL) ';
p_select_statement VARCHAR2(32767);
p_select_time := 'TEMP.period_year ';
p_select_period_setname := 'TEMP.period_set_name';
p_select_time := 'TEMP.period_quarter ';
p_select_period_setname := 'TEMP.period_set_name';
p_select_time := 'TEMP.period_month ';
p_select_period_setname := 'TEMP.period_set_name';
p_groupby_time := p_select_time || ', ' || p_select_period_setname;
p_select_org := 'TEMP.set_of_books_id ';
p_select_org := 'TEMP.legal_entity_id ';
p_select_org := 'TEMP.operating_unit_id ';
p_select_org := 'TEMP.organization_id ';
p_groupby_org := p_select_org;
p_select_geo := 'TEMP.area_code ';
p_groupby_geo := p_select_geo;
p_select_geo := 'TEMP.area_code || ''+'' ' ||
'|| TEMP.country_code ';
p_select_geo := 'TEMP.area_code || ''+'' ' ||
'|| TEMP.country_code || ''+'' || TEMP.region_code ';
p_select_product := 'TEMP.category_id ';
p_select_product := 'TEMP.inventory_item_id ';
p_groupby_product := p_select_product;
p_select_statement :=
'select ' ||
p_select_time || ', ' ||
p_select_period_setname || ', ' ||
p_select_org || ', ' ||
p_select_geo || ', ' ||
p_select_product || ', ' ||
' (decode(sum(TEMP.available_hours), 0, 0, ' ||
' sum(TEMP.actual_hours)/sum(TEMP.available_hours))*100) ' ||
'from ' ||
p_from || ' TEMP ' ||
'group by ' ||
p_groupby_time || ', ' ||
p_groupby_org || ', ' ||
p_groupby_geo || ', ' ||
p_groupby_product;
DBMS_SQL.PARSE( cursor_id, p_select_statement, DBMS_SQL.V7 );
SELECT MAX(set_of_books_id) INTO l_sob_id
FROM gl_sets_of_books
WHERE name = sob;
SELECT MAX(organization_id) INTO l_le_id
FROM hr_legal_entities
WHERE name = le;
SELECT MAX(organization_id) INTO l_ou_id
FROM hr_operating_units
WHERE name = ou;
SELECT MAX(organization_id) INTO l_org_id
FROM org_organization_definitions
WHERE organization_name = org;
SELECT MAX(id) INTO l_area_id
FROM bis_areas_v
WHERE name = area;
SELECT MAX(region_code) INTO l_region_id
FROM bis_regions_v
WHERE area_code = l_area_id AND country_code = l_country_id
AND name = region;
SELECT MAX(inventory_item_id) INTO l_item_id
FROM wip_bis_utz_cat_v
WHERE category_name = prod AND inventory_item_name = item;
/* SELECT clause */
p_select_time VARCHAR2(1000) := '-1 ';
p_select_start_date VARCHAR2(1000) := 'to_date(NULL) ';
p_select_end_date VARCHAR2(1000) := 'to_date(NULL) ';
p_select_org VARCHAR2(1000) := '-1 ';
p_select_geo VARCHAR2(1000) := '-1 ';
p_select_product VARCHAR2(1000) := '-1 ';
p_select_prod_id VARCHAR2(1000) := 'to_number(NULL) ';
p_select_sob_name VARCHAR2(1000) ;
p_select_le_name VARCHAR2(1000) ;
p_select_ou_name VARCHAR2(1000) ;
p_select_org_name VARCHAR2(1000) ;
p_select_area_name VARCHAR2(1000) ;
p_select_country_name VARCHAR2(1000) ;
p_select_country_id VARCHAR2(1000) := 'to_char(NULL) ';
p_select_prod_name VARCHAR2(1000) ;
p_select_item_name VARCHAR2(1000) ;
p_select_region_name VARCHAR2(1000) ;
p_select_statement VARCHAR2(32767);
p_select_sob_name := all_text;
p_select_le_name := all_text;
p_select_ou_name := all_text;
p_select_org_name := all_text;
p_select_area_name := all_text;
p_select_country_name := all_text;
p_select_prod_name := all_text;
p_select_item_name := all_text;
p_select_region_name := all_text;
p_select_start_date := 'gl_p.start_date '; -- Bug 3554853
p_select_end_date := 'gl_p.end_date '; -- Bug 3554853
p_select_time := 'TEMP.period_year ';
'and gl_p.start_date = (select max(gl_p.start_date) from gl_periods ' || -- Bug 3554853
'where period_set_name = TEMP.period_set_name ' ||
' and period_type = ''Year'') ';
p_select_start_date := 'gl_p.start_date '; -- Bug 3554853
p_select_end_date := 'gl_p.end_date '; -- Bug 3554853
p_select_time := 'TEMP.period_quarter ';
'and gl_p.start_date = (select max(gl_p.start_date) from gl_periods ' || -- Bug 3554853
'where period_set_name = TEMP.period_set_name ' ||
' and period_type = ''Quarter'') ';
p_select_start_date := 'gl_p.start_date '; -- Bug 3554853
p_select_end_date := 'gl_p.end_date '; -- Bug 3554853
p_select_time := 'TEMP.period_month ';
' (select max(gl_p.start_date) ' || -- Bug 3554853
' from gl_periods p, gl_sets_of_books sob ' ||
' where p.period_set_name = TEMP.period_set_name ' ||
' and sob.SET_OF_BOOKS_ID = TEMP.set_of_books_id ' ||
' and p.period_type = sob.ACCOUNTED_PERIOD_TYPE) ';
p_groupby_time := p_select_time || ', ' || p_select_start_date ||
', ' || p_select_end_date;
p_select_org := 'TEMP.set_of_books_id ';
p_select_sob_name := 'TEMP.set_of_books_name';
p_select_org := 'TEMP.legal_entity_id ';
p_select_sob_name := 'TEMP.set_of_books_name';
p_select_le_name := 'TEMP.legal_entity_name';
p_select_org := 'TEMP.operating_unit_id ';
p_select_sob_name := 'TEMP.set_of_books_name';
p_select_le_name := 'TEMP.legal_entity_name';
p_select_ou_name := 'TEMP.operating_unit_name';
p_select_org := 'TEMP.organization_id ';
p_select_sob_name := 'TEMP.set_of_books_name';
p_select_le_name := 'TEMP.legal_entity_name';
p_select_ou_name := 'TEMP.operating_unit_name';
p_select_org_name := 'TEMP.organization_name';
p_select_geo := 'TEMP.area_code ';
p_select_area_name := 'TEMP.area_name ';
p_groupby_geo := p_select_geo || ', ' || p_select_area_name;
p_select_geo := 'TEMP.country_code ' ;
p_select_area_name := 'TEMP.area_name ';
p_select_country_name := 'TEMP.country_name ';
p_groupby_geo := p_select_area_name || ', ' ||
p_select_geo || ', ' ||
p_select_country_name;
p_select_geo := 'TEMP.region_code ';
p_select_area_name := 'TEMP.area_name ';
p_select_country_name := 'TEMP.country_name ';
p_select_country_id := 'TEMP.country_code ';
p_select_region_name := 'TEMP.region_name ';
p_groupby_geo := p_select_area_name || ', ' ||
p_select_geo || ', ' ||
p_select_country_name || ', ' ||
p_select_country_id || ', ' || -- Added for bug 3570060
p_select_region_name;
p_select_product := 'TEMP.category_id ';
p_select_prod_name := 'TEMP.category_name ';
p_select_product := 'TEMP.inventory_item_id ';
p_select_prod_id := 'TEMP.category_id ';
p_select_prod_name := 'TEMP.category_name ';
p_select_item_name := 'TEMP.inventory_item_name ';
p_select_statement :=
'select ' ||
p_select_time || ', ' ||
p_select_org || ', ' ||
p_select_geo || ', ' ||
p_select_product || ', ' ||
p_select_prod_id || ', ' ||
p_select_sob_name || ', ' ||
p_select_le_name || ', ' ||
p_select_ou_name || ', ' ||
p_select_org_name || ', ' ||
p_select_area_name || ', ' ||
p_select_country_name || ', ' ||
p_select_prod_name || ', ' ||
p_select_item_name || ', ' ||
' (decode(sum(TEMP.available_hours), 0, 0, ' ||
' sum(TEMP.actual_hours)/sum(TEMP.available_hours))*100), ' ||
' trgt.target, ' ||
' bbp.plan_id, ' ||
' bbp.name, ' ||
' btl.workflow_process_short_name, ' ||
' min(trgt.range1_low), ' ||
' min(trgt.range1_high), ' ||
' min(trgt.range2_low), ' ||
' min(trgt.range2_high), ' ||
' min(trgt.range3_low), ' ||
' min(trgt.range3_high), ' ||
' min(trgt.notify_resp1_id), ' ||
' min(trgt.notify_resp2_id), ' ||
' min(trgt.notify_resp3_id), ' ||
' min(trgt.notify_resp1_short_name), ' ||
' min(trgt.notify_resp2_short_name), ' ||
' min(trgt.notify_resp3_short_name), ' ||
p_select_start_date || ', ' ||
p_select_end_date || ', ' ||
p_select_region_name || ', ' || /* James */
p_select_country_id || /* James */
'from ' ||
' bisbv_business_plans bbp, ' ||
' bisbv_targets trgt, ' ||
' bisbv_target_levels btl, ' ||
p_from_time || ' gl_p, ' || -- Bug 3554853
p_from || ' TEMP ' ||
'where btl.target_level_id = ' || ':target_level_id' ||
' and trgt.target_level_id = btl.target_level_id ' ||
' and bbp.plan_id = trgt.plan_id ' ||
p_where_trgt_time || ' ' ||
p_where_trgt_org || ' ' ||
p_where_trgt_geo || ' ' ||
p_where_trgt_prod || ' ' ||
'group by ' ||
p_groupby_time || ', ' ||
p_select_org || ', ' ||
p_select_sob_name || ', ' ||
p_select_le_name || ', ' ||
p_select_ou_name || ', ' ||
p_select_org_name || ', ' ||
p_groupby_org || ', ' ||
p_groupby_geo || ', ' ||
p_groupby_product || ', ' ||
'trgt.target, bbp.plan_id, bbp.name, ' ||
'btl.workflow_process_short_name ';
DBMS_SQL.PARSE( cursor_id, p_select_statement, DBMS_SQL.V7 );
/*INSERT INTO my_alert_test
VALUES(v_actual, v_target, v_range1_low, v_range1_high, v_range2_low,
v_range2_high, v_range3_low, v_range3_high, v_time, v_org,
v_geography, v_product);*/
select name from wf_roles
where name = p_role;
select bis_excpt_wf_s.nextval
into l_wf_item_key
from dual;
select btl.target_level_id target_level_id,
decode(tltime.dimension_level_short_name,
'TOTAL_TIME', 0,
'YEAR', 1,
'QUARTER', 2,
'MONTH', 3) time_value,
decode(tlorg.dimension_level_short_name,
'SET OF BOOKS', 1,
'LEGAL ENTITY', 2,
'OPERATING UNIT', 3,
'ORGANIZATION', 4) org_value,
decode(tlgeo.dimension_level_short_name,
'TOTAL GEOGRAPHY', 1,
'AREA', 2,
'COUNTRY', 3,
'REGION', 4) geo_value, /* James 7/8/99 */
decode(tlcat.dimension_level_short_name,
'TOTAL PRODUCTS', 1,
'PRODUCT GROUP', 2,
'ITEM', 3) prod_value
from bisbv_performance_measures bpm,
bisbv_target_levels btl,
bisbv_dimension_levels tltime,
bisbv_dimension_levels tlorg,
bisbv_dimension_levels tlgeo,
bisbv_dimension_levels tlcat
where bpm.measure_short_name = 'WIPBIUZIND'
and btl.measure_id = bpm.measure_id
and btl.time_level_id = tltime.dimension_level_id
and btl.org_level_id = tlorg.dimension_level_id
and btl.dimension1_level_id = tlgeo.dimension_level_id
and btl.dimension2_level_id = tlcat.dimension_level_id;