The following lines contain the word 'select', 'insert', 'update' or 'delete':
tableinsert VARCHAR2(5000);
tableinsert := 'INSERT INTO ' || p_temp_table || '(MEMBER, ';
tableinsert := tableinsert || ' LEVEL_TYPE, MEMBER_ORDER, USER_ID, ';
tableinsert := tableinsert || p_dimensions(counter);
tableinsert := tableinsert || ')';
tableinsert := tableinsert || ', ';
EXECUTE IMMEDIATE tableinsert || tablevalues;
tableSelect VARCHAR2(5000);
SELECT DISTINCT(Dimension) bulk collect into dimensions
FROM zpb_solve_output_levels
WHERE ANALYSIS_CYCLE_ID = p_ac_id
ORDER BY Dimension;
tableSelect := 'DELETE FROM ' || p_temp_table || ' WHERE USER_ID = ' ;
tableSelect := tableSelect || p_userid || ' AND LEVEL_TYPE = ''' || INPUT_TYPE || '''';
EXECUTE IMMEDIATE tableSelect;
tableSelect := 'SELECT DISTINCT def.member, def.member_order, ';
tableSelect := tableSelect || ' nvl(input.dimension, ';
tableSelect := tableSelect || '''' || '-'|| '''';
tableSelect := tableSelect || ') AS dimension,';
tableSelect := tableSelect || ' levellookup.OBJECT_LONG_LABEL
AS input_level, def.SOURCE_TYPE ';
tableSelect := tableSelect || ' FROM ((zpb_solve_member_defs def ';
tableSelect := tableSelect || ' LEFT OUTER JOIN zpb_solve_input_levels input
ON def.member = input.member
AND def.ANALYSIS_CYCLE_ID = input.ANALYSIS_CYCLE_ID)
LEFT OUTER JOIN ZPB_SESSION_METADATA_LABELS levellookup ';
tableSelect := tableSelect ||
'ON levellookup.dimension = input.dimension
AND levellookup.OBJECT_AW_NAME = input.input_level ';
tableSelect := tableSelect || ' AND levellookup.USER_ID = ' || p_userid ;
tableSelect := tableSelect || ' AND levellookup.OBJECT_TYPE = ';
tableSelect := tableSelect || '''' || 'LEVEL' || '''' || ')';
tableSelect := tableSelect || ' WHERE def.ANALYSIS_CYCLE_ID = ';
tableSelect := tableSelect || p_ac_id;
tableSelect := tableSelect || ' ORDER BY 1, 3';
OPEN c4 FOR tableSelect;
tableSelect := 'SELECT OBJECT_LONG_LABEL' ||
' FROM ZPB_SESSION_METADATA_LABELS' ||
' WHERE USER_ID = ' || p_userid ||
' AND OBJECT_TYPE = ''' || 'DIMENSION' || '''' ||
' AND OBJECT_AW_NAME IN' ||
' (SELECT Dimension FROM ZPB_SOLVE_OUTPUT_LEVELS' ||
' WHERE ANALYSIS_CYCLE_ID = ' || p_ac_id || ')' ||
' ORDER BY Dimension';
OPEN labelCursor FOR tableSelect;
tableSelect := 'SELECT solvetemp.MEMBER as member, memberlookup.';
tableSelect := tableSelect || p_view_long_lbl_column || ' as MemberName, ';
tableselect := tableselect || 'solvetemp.' || dimensions(indx);
tableselect := tableselect || ', ';
tableselect := tableselect || ' FROM ' || p_temp_table || ' solvetemp, ';
tableselect := tableselect || p_view_dim_name || ' memberlookup ';
tableselect := tableselect || ' WHERE solvetemp.LEVEL_TYPE = ''' || INPUT_TYPE || '''';
tableselect := tableselect || ' AND solvetemp.MEMBER = memberlookup.';
tableselect := tableselect || p_view_member_column;
tableselect := tableselect || ' ORDER BY solvetemp.MEMBER_ORDER';
OPEN dataCursor FOR tableSelect;
tableSelect VARCHAR2(5000);
SELECT DISTINCT(Dimension) bulk collect into dimensions
FROM zpb_solve_output_levels
WHERE ANALYSIS_CYCLE_ID = p_ac_id
ORDER BY Dimension;
tableSelect := 'DELETE FROM ' || p_temp_table || ' WHERE USER_ID = ' ;
tableSelect := tableSelect || p_userid || ' AND LEVEL_TYPE = ''' || OUTPUT_TYPE || '''';
EXECUTE IMMEDIATE tableSelect;
tableSelect := 'SELECT distinct output.member, output.member_order, ';
tableSelect := tableSelect || ' output.dimension AS dimension,
output.hierarchy AS hierarchy,
levellookup.OBJECT_LONG_LABEL AS output_level
FROM zpb_solve_output_levels output ';
tableSelect := tableSelect || ' INNER JOIN ZPB_SESSION_METADATA_LABELS levellookup
ON levellookup.dimension = output.dimension
AND levellookup.OBJECT_AW_NAME = output.output_level
WHERE output.ANALYSIS_CYCLE_ID = ';
tableSelect := tableSelect || p_ac_id;
tableSelect := tableSelect || ' AND levellookup.USER_ID = ' || p_userid ;
tableSelect := tableSelect || ' AND levellookup.OBJECT_TYPE = ';
tableSelect := tableSelect || '''' || 'LEVEL' || '''';
tableSelect := tableSelect || ' ORDER BY output.member, output.dimension';
OPEN c4 FOR tableSelect;
tableSelect := 'SELECT OBJECT_LONG_LABEL' ||
' FROM ZPB_SESSION_METADATA_LABELS' ||
' WHERE USER_ID = ' || p_userid ||
' AND OBJECT_TYPE = ''' || 'DIMENSION' || '''' ||
' AND OBJECT_AW_NAME IN' ||
' (SELECT Dimension FROM ZPB_SOLVE_OUTPUT_LEVELS' ||
' WHERE ANALYSIS_CYCLE_ID = ' || p_ac_id || ')' ||
' ORDER BY Dimension';
OPEN labelCursor FOR tableSelect;
tableSelect := 'SELECT solvetemp.MEMBER as member, memberlookup.';
tableSelect := tableSelect || p_view_long_lbl_column || ' as MemberName, ';
tableselect := tableselect || 'solvetemp.' || dimensions(indx);
tableselect := tableselect || ', ';
tableselect := tableselect || ' FROM ' || p_temp_table || ' solvetemp, ';
tableselect := tableselect || p_view_dim_name || ' memberlookup ';
tableselect := tableselect || ' WHERE solvetemp.LEVEL_TYPE = ''' || OUTPUT_TYPE || '''';
tableselect := tableselect || ' AND solvetemp.MEMBER = memberlookup.';
tableselect := tableselect || p_view_member_column;
tableselect := tableselect || ' ORDER BY solvetemp.MEMBER_ORDER';
OPEN dataCursor FOR tableSelect;