The following lines contain the word 'select', 'insert', 'update' or 'delete':
p_update_type varchar2,
p_load_pk number,
p_op_table_space varchar2,
p_dim_push_down out NOCOPY boolean,
p_rollback varchar2,
p_thread_type varchar2,
p_max_threads number,
p_min_job_load_size number,
p_sleep_time number,
p_hash_area_size number,
p_sort_area_size number,
p_trace boolean,
p_read_cfig_options boolean,
p_join_nl_percentage number
) return boolean is
l_status number;
g_update_type:=p_update_type;
if g_update_type='DELETE-INSERT' then
g_update_type:='MASS';
g_level_full_insert,
g_debug,
g_parallel,
g_collection_size,
g_bis_owner,
g_table_owner,
g_full_refresh,
g_forall_size,
g_update_type,
g_load_pk,
g_op_table_space,
g_rollback,
g_max_threads,
g_min_job_load_size,
g_sleep_time,
g_hash_area_size,
g_sort_area_size,
g_trace,
g_read_cfig_options,
g_join_nl_percentage
)=false then
return false;
if EDW_OWB_COLLECTION_UTIL.delete_conc_program(
l_temp_conc_short_name,
l_temp_exe_name,
l_bis_short_name,
'SHORT')=false then
null;
l_stmt:='select lvl.level_prefix, lvl.level_name||''_LTC'' from edw_levels_md_v lvl where lvl.level_name '||
'in ('||l_in_stmt||')';
l_stmt:='select lookup_code,meaning from FND_LOOKUP_VALUES_VL where lookup_type=''EDW_LEVEL_PUSH_DOWN'' '||
' and lookup_code in ('||l_in_stmt||')';
insert_into_load_progress_d(g_load_pk,g_level_order(i),'Push Down Level '||g_jobid_stmt,sysdate,null,'LEVEL',
'LEVEL-PUSH-DOWN','LPD'||i||g_jobid_stmt,'I');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'LPD'||i||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'LPD'||i||g_jobid_stmt,'U');
function execute_update_stmt(p_update_stmt varchar2,p_update_stmt_row varchar2,p_update_rowid_table varchar2)
return boolean is
l_stmt varchar2(5000);
l_update_type varchar2(400);
write_to_log_file_n('In execute_update_stmt '||get_time);
l_update_type:=g_update_type;
<>
if l_update_type='ROW-BY-ROW' then
l_stmt:='select row_id from '||p_update_rowid_table;
execute immediate p_update_stmt_row using l_rowid(i),l_rowid(i);
execute immediate p_update_stmt_row using l_rowid(i),l_rowid(i);
elsif l_update_type='MASS' then
EDW_OWB_COLLECTION_UTIL.alter_session('NO-PARALLEL');
execute immediate p_update_stmt;
write_to_log_file_n('Memory issue with Mass Update. Retrying using ROW_BY_ROW');
l_update_type:='ROW-BY-ROW';
goto start_update;
write_to_log_file('Problem stmt '||p_update_stmt);
write_to_log_file_n('Number of rows updated '||l_total_count||get_time);
if g_skip_ilog_update(l_parent_index)=false then
l_status:=set_gilog_status(g_level_ilog(l_parent_index),l_parent_index);
g_skip_ilog_update(l_parent_index):=false;
if g_type_ilog_generation='UPDATE' then
if update_gilog(g_level_ilog(l_parent_index))=false then
write_to_log_file_n('Error in update_gilog');
l_update_stmt varchar2(32000);
l_update_stmt_row varchar2(32000);
l_insert_stmt varchar2(32000);
l_stmt:=l_stmt||' as select /*+ordered ';
if g_level_full_insert(l_child_index) then
--only insert
if g_debug then
write_to_log_file_n('Full Insert');
l_stmt:='insert into '||p_child_level||'('||l_user_pk||','||l_pk;
l_stmt:=l_stmt||',NAME,CREATION_DATE,LAST_UPDATE_DATE,PUSHED_DOWN_FLAG) select ';
write_to_log_file_n('Inserted '||sql%rowcount||' rows '||get_time);
l_opcode_table:=g_update_rowid(l_child_index)||'O';
l_stmt:=l_stmt||' as select ';
write_to_log_file_n('Update needed for child level');
l_stmt:='create table '||g_update_rowid(l_child_index)||' tablespace '||g_op_table_space;
l_stmt:=l_stmt||' as select ';
if EDW_OWB_COLLECTION_UTIL.drop_table(g_update_rowid(l_child_index))=false then
null;
l_stmt:='create unique index '||g_update_rowid(l_child_index)||'u on '||
g_update_rowid(l_child_index)||'(row_id) tablespace '||g_op_table_space;
l_table:=g_update_rowid(l_child_index);
l_update_stmt:='update /*+ORDERED USE_NL('||p_child_level||')*/ '||p_child_level||' set '||
'(NAME,LAST_UPDATE_DATE,PUSHED_DOWN_FLAG';
l_update_stmt_row:='update '||p_child_level||' set (NAME,LAST_UPDATE_DATE,PUSHED_DOWN_FLAG';
l_update_stmt:=l_update_stmt||','||g_final_fk(l_final(i));
l_update_stmt_row:=l_update_stmt_row||','||g_final_fk(l_final(i));
l_update_stmt:=l_update_stmt||','||l_other_fks(i);
l_update_stmt_row:=l_update_stmt_row||','||l_other_fks(i);
l_update_stmt:=l_update_stmt||')=(select NAME,SYSDATE,''Y''';
l_update_stmt_row:=l_update_stmt_row||')=(select NAME,SYSDATE,''Y''';
l_update_stmt:=l_update_stmt||','||g_final_fk(l_final(i));
l_update_stmt_row:=l_update_stmt_row||','||g_final_fk(l_final(i));
l_update_stmt:=l_update_stmt||','||l_other_fks(i);
l_update_stmt_row:=l_update_stmt_row||','||l_other_fks(i);
l_update_stmt:=l_update_stmt||' from '||g_update_rowid(l_child_index)||' where '||
g_update_rowid(l_child_index)||'.row_id='||p_child_level||'.rowid) where '||p_child_level||'.rowid in '||
'(select row_id from '||g_update_rowid(l_child_index)||')';
l_update_stmt_row:=l_update_stmt_row||' from '||g_update_rowid(l_child_index)||' where '||
g_update_rowid(l_child_index)||'.row_id=:a) where '||p_child_level||'.rowid=:b';
write_to_log_file_n('MASS Update stmt '||l_update_stmt);
write_to_log_file_n('ROW-BY-ROW Update stmt '||l_update_stmt_row);
if execute_update_stmt(l_update_stmt,l_update_stmt_row,g_update_rowid(l_child_index))=false then
return false;
if EDW_OWB_COLLECTION_UTIL.drop_table(g_update_rowid(l_child_index))=false then
null;
write_to_log_file_n('Insert needed for child level');
l_insert_stmt:='insert into '||p_child_level||'('||l_user_pk||','||l_pk;
l_insert_stmt:=l_insert_stmt||','||g_final_fk(l_final(i));
l_insert_stmt:=l_insert_stmt||','||l_other_fks(i);
l_insert_stmt:=l_insert_stmt||',NAME,CREATION_DATE,LAST_UPDATE_DATE,PUSHED_DOWN_FLAG) select ';
l_insert_stmt:=l_insert_stmt||' /*+parallel(A,'||g_parallel||')*/ ';
l_insert_stmt:=l_insert_stmt||'A.'||l_parent_user_pk||'||''-'||g_level_prefix(l_parent_index)||''''||
','||g_level_seq(l_child_index)||'.NEXTVAL';
l_insert_stmt:=l_insert_stmt||',A.'||g_final_pk_value(l_final(i));
l_insert_stmt:=l_insert_stmt||','||g_ltc_copy(l_level_copy_index(l_index))||'.'||g_final_next_pk(l_final(i));
l_insert_stmt:=l_insert_stmt||','||l_diamond_fk_table||'.'||l_other_fks(i);
l_insert_stmt:=l_insert_stmt||',0 ';
l_insert_stmt:=l_insert_stmt||','''||g_level_display_prefix(l_child_index)||
'(''||A.NAME||'')'',SYSDATE,SYSDATE,''Y'' from '||l_opcode_table||','||p_parent_level||' A ';
l_insert_stmt:=l_insert_stmt||','||g_ltc_copy(l_level_copy_index(i));
l_insert_stmt:=l_insert_stmt||','||l_diamond_fk_table;
l_insert_stmt:=l_insert_stmt||' where '||l_opcode_table||'.row_id=A.rowid and '||
l_opcode_table||'.status=0 and ';
l_insert_stmt:=l_insert_stmt||'A.rowid='||g_ltc_copy(l_level_copy_index(i))||'.row_id and ';
l_insert_stmt:=l_insert_stmt||'A.rowid='||l_diamond_fk_table||'.row_id and ';
l_insert_stmt:=substr(l_insert_stmt,1,length(l_insert_stmt)-4);
write_to_log_file_n('Going to execute Insert stmt '||l_insert_stmt||get_time);
execute immediate l_insert_stmt;
write_to_log_file_n('Inserted '||sql%rowcount||' rows '||get_time);
function update_gilog(p_ilog varchar2) return boolean is
l_stmt varchar2(2000);
write_to_log_file_n('In update_gilog for '||p_ilog||get_time);
l_stmt:='update '||p_ilog||' set status=2 where status=1';
write_to_log_file_n('Updated '||sql%rowcount||' rows from 1 to 2 for '||p_ilog||get_time);
this function sets the status of the ilog from 0 to 1 and also deletes those that are 1 first
returns:
0: error
1: no more records to change from 0 to 1
2: success
*/
function set_gilog_status(p_ilog in out NOCOPY varchar2,p_index number) return number is
l_stmt varchar2(10000);
if g_type_ilog_generation='UPDATE' then
if EDW_OWB_COLLECTION_UTIL.does_table_have_data(p_ilog,'status=1')=2 then
return 2;
l_stmt:='update '||p_ilog||' set status=1 where status=0';
l_stmt:='update '||p_ilog||' set status=1 where status=0 and rownum <='||g_collection_size;
write_to_log_file_n('Updated '||l_count||' rows in '||p_ilog||get_time);
l_stmt:=l_stmt||' as select row_id,'||l_ltc_pk||',decode(status,1,2,2,2,decode(sign(rownum-'||
g_collection_size||'),1,0,1)) status from (select row_id,'||l_ltc_pk||',status from '||p_ilog||
' order by status) abc ';
l_stmt:=l_stmt||' as select row_id,decode(status,1,2,2,2,decode(sign(rownum-'||
g_collection_size||'),1,0,1)) status from (select row_id,status from '||p_ilog||' order by status) abc ';
l_stmt:=l_stmt||' as select row_id,'||l_ltc_pk||',decode(status,1,2,0,1,2) status from '||
p_ilog;
l_stmt:=l_stmt||' as select row_id,decode(status,1,2,0,1,2) status from '||
p_ilog;
g_skip_ilog_update(i):=false;
g_insert_rowid(i):=g_bis_owner||'.'||l_name||'IR';
g_update_rowid(i):=g_bis_owner||'.'||l_name||'UR';
g_level_full_insert(i):=false;--default
g_level_full_insert(i):=true;
g_level_full_insert(i):=true;
l_stmt:='select seq.sequence_name, rel.name from edw_tables_md_v rel, edw_pvt_sequences_md_v seq, '||
'edw_pvt_map_properties_md_v map, edw_pvt_map_sources_md_v ru where rel.name in ('||l_in_stmt||') '||
'and map.primary_target=rel.elementid and ru.mapping_id=map.mapping_id '||
'and ru.source_id=seq.sequence_id ';
if EDW_OWB_COLLECTION_UTIL.drop_table(g_update_rowid(i))=false then
null;
if EDW_OWB_COLLECTION_UTIL.drop_table(g_insert_rowid(i))=false then
null;
l_stmt:=l_stmt||' as select chartorowid(M_ROW$$) row_id ';
l_stmt:='insert into '||g_level_ilog(l_index)||'(row_id,'||g_level_pk(l_index)||',status) select ';
l_stmt:='insert into '||g_level_ilog(l_index)||'(row_id, status) select ';
l_stmt:='insert into '||g_level_ilog(l_index)||'(row_id,'||g_level_pk(l_index)||',status) select ';
l_stmt:='insert into '||g_level_ilog(l_index)||'(row_id, status) select ';
l_stmt:=l_stmt||' as select /*+ordered*/ A.rowid row_id';
l_stmt:=l_stmt||' as select /*+ordered ';
l_stmt:=l_stmt||' as select ';
'MINUS select ';
l_stmt:='insert into '||g_level_ilog(l_index)||'(row_id,'||g_level_pk(l_index)||',status) select '||
'row_id,'||g_level_pk(l_index)||',status from '||l_level_ilog_el;
l_stmt:='insert into '||g_level_ilog(l_index)||'(row_id, status) select '||
'row_id,status from '||l_level_ilog_el;
procedure insert_into_load_progress_d(p_load_fk number,p_object_name varchar2,p_load_progress varchar2,
p_start_date date,p_end_date date,p_category varchar2, p_operation varchar2,p_seq_id varchar2,p_flag varchar2) is
Begin
if g_debug then
EDW_OWB_COLLECTION_UTIL.insert_into_load_progress(p_load_fk,p_object_name,g_level_id,p_load_progress,
p_start_date,p_end_date,p_category,p_operation,p_seq_id,p_flag,g_level_id);
l_stmt:=l_stmt||' as select row_id from '||p_ilog||' where status=1';
l_stmt:='select parent_level.level_name||''_LTC'',child_level.level_name||''_LTC'', hier.hier_name '||
'from '||
'edw_pvt_level_relation_md_v lvl_rel, '||
'edw_hierarchies_md_v hier, '||
'edw_dimensions_md_v dim, '||
'edw_levels_md_v child_level, '||
'edw_levels_md_v parent_level '||
'where '||
'dim.dim_name=:a '||
'and hier.dim_id=dim.dim_id '||
'and lvl_rel.hierarchy_id=hier.hier_id '||
'and child_level.level_id=lvl_rel.child_level_id '||
'and parent_level.level_id=lvl_rel.parent_level_id';
l_stmt:=l_stmt||' as select /*+ordered*/ ';
l_stmt:=l_stmt||' as select max(row_num) row_num,'||p_child_fk_order(p_number_level_order)||' from '||
l_diamond_table||' group by '||p_child_fk_order(p_number_level_order);
l_stmt:=l_stmt||' as select /*+ordered*/ A.row_id';
g_skip_ilog_update(i):=true;
l_level_full_insert varchar2(10);
g_stmt:='select '||
'dim_id'||
',debug'||
',parallel'||
',collection_size'||
',bis_owner'||
',table_owner'||
',full_refresh'||
',forall_size'||
',update_type'||
',load_pk'||
',op_table_space'||
',rollback'||
',max_threads'||
',min_job_load_size'||
',sleep_time'||
',hash_area_size'||
',sort_area_size'||
',trace'||
',read_cfig_options'||
',join_nl_percentage'||
' from '||p_input_table;
,g_update_type
,g_load_pk
,g_op_table_space
,g_rollback
,g_max_threads
,g_min_job_load_size
,g_sleep_time
,g_hash_area_size
,g_sort_area_size
,l_trace
,l_read_cfig_options
,g_join_nl_percentage;
write_to_log_file('g_update_type='||g_update_type);
g_stmt:='select '||
'levels'||
',child_level_number'||
',level_order'||
',level_snapshot_logs'||
',level_ilog'||
',level_consider'||
',level_full_insert '||
' from '||l_level_table||' order by level_number';
,l_level_full_insert;
g_level_full_insert(g_number_levels):=false;
if l_level_full_insert='Y' then
g_level_full_insert(g_number_levels):=true;
if g_level_full_insert(i) then
write_to_log_file('g_level_full_insert('||i||') TRUE');
write_to_log_file('g_level_full_insert('||i||') FALSE');
g_stmt:='select '||
'child_levels'||
',child_fk'||
',parent_pk from '||l_level_child_table||' order by run_number';