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 := 'bth.parent_territory_code ';
p_groupby_geo := p_select_geo;
p_select_geo := 'bth.parent_territory_code || ''+'' ' ||
'|| TEMP.country_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.total_quantity), 0, 0, ' ||
' (sum(TEMP.total_quantity) - ' ||
' sum(TEMP.scrap_quantity))/sum(TEMP.total_quantity))*100) ' ||
'from ' ||
p_from_geo || ' bth, ' ||
p_from || ' TEMP ' ||
'where ' ||
p_where_geo || ' ' ||
'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 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_prod_name VARCHAR2(1000) ;
p_select_item_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_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 := 'bth.parent_territory_code';
p_select_area_name := 'bth.parent_territory_name ';
p_groupby_geo := p_select_geo || ', ' || p_select_area_name;
p_select_geo := 'TEMP.country_code ' ;
p_select_area_name := 'bth.parent_territory_name ';
p_select_country_name := 'bth.child_territory_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.total_quantity), 0, 0, ' ||
' (sum(TEMP.total_quantity) - ' ||
' sum(TEMP.scrap_quantity))/sum(TEMP.total_quantity))*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 ||
'from ' ||
' bisbv_business_plans bbp, ' ||
' bisbv_targets trgt, ' ||
' bisbv_target_levels btl, ' ||
p_from_time || ' gl_p, ' || --Bug 3554853
p_from_geo || ' bth, ' ||
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_output.put_line (substr(p_select_statement,1,100));
dbms_output.put_line (substr(p_select_statement,100,100));
dbms_output.put_line (substr(p_select_statement,200,100));
dbms_output.put_line (substr(p_select_statement,300,100));
dbms_output.put_line (substr(p_select_statement,400,100));
dbms_output.put_line (substr(p_select_statement,500,100));
dbms_output.put_line (substr(p_select_statement,600,100));
dbms_output.put_line (substr(p_select_statement,700,100));
dbms_output.put_line (substr(p_select_statement,800,100));
dbms_output.put_line (substr(p_select_statement,900,100));
dbms_output.put_line (substr(p_select_statement,1000,100));
dbms_output.put_line (substr(p_select_statement,1100,100));
dbms_output.put_line (substr(p_select_statement,1200,100));
dbms_output.put_line (substr(p_select_statement,1300,100));
dbms_output.put_line (substr(p_select_statement,1400,100));
dbms_output.put_line (substr(p_select_statement,1500,100)); */
DBMS_SQL.PARSE( cursor_id, p_select_statement, DBMS_SQL.V7 );
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,
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 = 'WIPBIYD'
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;