The following lines contain the word 'select', 'insert', 'update' or 'delete':
p_update_type varchar2,
p_level_order EDW_OWB_COLLECTION_UTIL.varcharTableType,
p_skip_cols EDW_OWB_COLLECTION_UTIL.varcharTableType,
p_number_skip_cols number,
p_load_pk number,
p_fresh_restart boolean,
p_op_table_space varchar2,
p_rollback varchar2,
p_ltc_merge_use_nl boolean,
p_dim_inc_refresh_derv boolean,
p_check_fk_change boolean,
p_ok_switch_update number,
p_join_nl_percentage number,
p_thread_type varchar2,
p_max_threads number,
p_min_job_load_size number,
p_sleep_time number,
p_job_status_table varchar2,
p_hash_area_size number,
p_sort_area_size number,
p_trace boolean,
p_read_cfig_options boolean,
p_max_fk_density number,
p_analyze_frequency number,
p_parallel_drill_down boolean,
p_dd_status_table varchar2
) is
Begin
if p_max_threads>1 then
--multi threaded
collect_dimension_multi_thread(
p_conc_id,
p_conc_name,
p_dim_name,
p_levels,
p_child_level_number,
p_child_levels,
p_child_fk,
p_parent_pk,
p_level_snapshot_logs,
p_number_levels,
p_debug,
p_exec_flag,
p_bis_owner,
p_parallel,
p_collection_size,
p_table_owner,
p_forall_size,
p_update_type,
p_level_order,
p_skip_cols,
p_number_skip_cols,
p_load_pk,
p_fresh_restart,
p_op_table_space,
p_rollback,
p_ltc_merge_use_nl,
p_dim_inc_refresh_derv,
p_check_fk_change,
p_ok_switch_update,
p_join_nl_percentage,
p_thread_type,
p_max_threads,
p_min_job_load_size,
p_sleep_time,
p_job_status_table,
p_hash_area_size,
p_sort_area_size,
p_trace,
p_read_cfig_options,
p_max_fk_density,
p_analyze_frequency,
p_parallel_drill_down,
p_dd_status_table
);
p_update_type,
p_level_order,
p_skip_cols,
p_number_skip_cols,
p_load_pk,
p_fresh_restart,
p_op_table_space,
p_rollback,
p_ltc_merge_use_nl,
p_dim_inc_refresh_derv,
p_check_fk_change,
p_ok_switch_update,
p_join_nl_percentage,
p_read_cfig_options,
p_max_fk_density,
p_analyze_frequency
);
p_update_type varchar2,
p_level_order EDW_OWB_COLLECTION_UTIL.varcharTableType,
p_skip_cols EDW_OWB_COLLECTION_UTIL.varcharTableType,
p_number_skip_cols number,
p_load_pk number,
p_fresh_restart boolean,
p_op_table_space varchar2,
p_rollback varchar2,
p_ltc_merge_use_nl boolean,
p_dim_inc_refresh_derv boolean,
p_check_fk_change boolean,
p_ok_switch_update number,
p_join_nl_percentage number,
p_thread_type varchar2,
p_max_threads number,
p_min_job_load_size number,
p_sleep_time number,
p_job_status_table varchar2,
p_hash_area_size number,
p_sort_area_size number,
p_trace boolean,
p_read_cfig_options boolean,
p_max_fk_density number,
p_analyze_frequency number,
p_parallel_drill_down boolean,
p_dd_status_table varchar2
) is
l_input_table varchar2(200);
g_update_type :=p_update_type;
g_ok_switch_update:=p_ok_switch_update;
p_update_type,
p_level_order,
p_skip_cols,
p_number_skip_cols,
p_load_pk,
p_fresh_restart,
p_op_table_space,
p_rollback,
p_ltc_merge_use_nl,
p_dim_inc_refresh_derv,
p_check_fk_change,
p_ok_switch_update,
p_join_nl_percentage,
p_max_threads,
p_min_job_load_size,
p_sleep_time,
p_job_status_table,
p_hash_area_size,
p_sort_area_size,
p_trace,
p_read_cfig_options,
p_max_fk_density
)=false then
g_status_message:=EDW_OWB_COLLECTION_UTIL.get_status_message;
insert_into_star;
if EDW_OWB_COLLECTION_UTIL.update_dim_load_input_table(
l_input_table,
l_ilog_table,
g_skip_ilog_update,
g_level_change,--to recreate from stmt etc
g_dim_empty_flag,
g_before_update_table_final,
g_error_rec_flag,
g_consider_snapshot,
g_levels_I,
g_use_ltc_ilog,
g_number_levels
)=false then
g_status_message:=EDW_OWB_COLLECTION_UTIL.get_status_message;
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;
if drop_prot_table(g_insert_prot_table,g_insert_prot_table_active)=false then
null;
if drop_prot_table(g_bu_insert_prot_table,g_bu_insert_prot_table_active)=false then
null;
the following must be updated into the inp table
g_skip_ilog_update
g_level_change --to recreate from stmt etc
g_dim_empty_flag
g_before_update_table_final
*/
g_max_threads:=p_max_threads;
insert_into_load_progress_d(g_load_pk,g_dim_name,'Read Metadata'||g_jobid_stmt,sysdate,null,'DIMENSION',
'METADAT','RM'||g_job_id,'I');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'RM'||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'RM'||g_job_id,'U');
make_select_from_where_stmt;
make_select_from_where_ins;
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'RM'||g_job_id,'U');
if initial_insert_into_star(true)=false then
return false;
insert_into_load_progress_d(g_load_pk,g_dim_name,'Load ILOG'||g_jobid_stmt,sysdate,null,'DIMENSION',
'INSERT','IL2010'||g_job_id,'I');
insert_into_ilog(true);--multi threading true
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'IL2010'||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,g_dim_name,'Create Protection Table'||g_jobid_stmt,sysdate,null,'DIMENSION',
'INSERT','CPTBL'||g_job_id,'I');
if create_prot_table(g_bu_insert_prot_table,g_bu_insert_prot_table_active)=false then
g_status:=false;
if get_before_update_table_name=false then
g_status:=false;
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CPTBL'||g_job_id,'U');
becasue init_all resets many of the global variables that we updated into the inp table,
will have to read again
*/
if read_options_table(p_table_name)=false then
return false;
insert_into_load_progress_d(g_load_pk,g_dim_name,'Read Metadata'||g_jobid_stmt,sysdate,null,'DIMENSION',
'METADAT','RM'||g_job_id,'I');
make_select_from_where_stmt;
make_select_from_where_ins;
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'RM'||g_job_id,'U');
insert_into_star;
p_update_type varchar2,
p_level_order EDW_OWB_COLLECTION_UTIL.varcharTableType,
p_skip_cols EDW_OWB_COLLECTION_UTIL.varcharTableType,
p_number_skip_cols number,
p_load_pk number,
p_fresh_restart boolean,
p_op_table_space varchar2,
p_rollback varchar2,
p_ltc_merge_use_nl boolean,
p_dim_inc_refresh_derv boolean,
p_check_fk_change boolean,
p_ok_switch_update number,
p_join_nl_percentage number,
p_read_cfig_options boolean,
p_max_fk_density number,
p_analyze_frequency number
) is
--get the mapping details for dim
--also used to see if slowly changing dim is implemented
begin
g_dim_name:=p_dim_name;
g_update_type :=p_update_type;
g_ok_switch_update:=p_ok_switch_update;
write_to_log_file('g_ok_switch_update='||g_ok_switch_update);
insert_into_load_progress_d(g_load_pk,g_dim_name,'Read Metadata'||g_jobid_stmt,sysdate,null,'DIMENSION',
'METADAT','RM'||g_job_id,'I');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'RM'||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'RM'||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'RM'||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'RM'||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'RM'||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'RM'||g_job_id,'U');
make_select_from_where_stmt;
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'RM'||g_job_id,'U');
make_select_from_where_ins;
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'RM'||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'RM'||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'RM'||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,g_dim_name,'Create Protection Table'||g_jobid_stmt,sysdate,null,'DIMENSION',
'INSERT','CPTBL'||g_job_id,'I');
if create_prot_table(g_insert_prot_table,g_insert_prot_table_active)=false then
g_status:=false;
if create_prot_table(g_bu_insert_prot_table,g_bu_insert_prot_table_active)=false then
g_status:=false;
if get_before_update_table_name=false then
g_status:=false;
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CPTBL'||g_job_id,'U');
if drop_prot_table(g_insert_prot_table,g_insert_prot_table_active)=false then
null;
if drop_prot_table(g_bu_insert_prot_table,g_bu_insert_prot_table_active)=false then
null;
if initial_insert_into_star(false)=false then
return;
insert_into_star;
insert_into_load_progress_d(g_load_pk,g_dim_name,'Load ILOG'||g_jobid_stmt,sysdate,null,'DIMENSION',
'INSERT','IL2010'||g_job_id,'I');
insert_into_ilog(false);
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'IL2010'||g_job_id,'U');
make_temp_insert_sql;--to insert into the temp int table
write_to_log_file_n('g_temp_insert_stmt is ');
write_to_log_file(g_temp_insert_stmt);
make_hold_insert_stmt;
write_to_log_file_n('The hold table insert stmt is '||g_hold_insert_stmt);
make_insert_update_stmt_star;
write_to_log_file_n('The insert stmt into star is '||g_insert_stmt_star);
write_to_log_file_n('The update stmt into star is '||g_update_stmt_star);
if g_skip_ilog_update=false then
l_status:=set_gilog_status;
g_skip_ilog_update:=false;
g_skip_ilog_update:=false;
write_to_log_file('Moved a total of '||g_number_rows_inserted||' records into the star table');
insert_into_load_progress_d(g_load_pk,g_dim_name,'Determine Incremental Data'||g_jobid_stmt,
sysdate,null,'DIMENSION','CREATE-TABLE','CDVT2000'||l_count||' '||g_job_id,'I');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CDVT2000'||l_count||' '||
g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CDVT2000'||l_count||' '||
g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CDVT2000'||l_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CDVT2000'||l_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CDVT2000'||l_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,g_dim_name,'Pre proccess Dimension Data'||g_jobid_stmt,
sysdate,null,'DIMENSION','INSERT','CDVT2010'||l_count||' '||g_job_id,'I');
execute_temp_insert_sql;--move the data into int temp table
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CDVT2010'||l_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CDVT2010'||l_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CDVT2010'||l_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CDVT2010'||l_count||' '||g_job_id,'U');
if g_insert_star_flag then
insert_into_load_progress_d(g_load_pk,g_dim_name,'Drill Up for all levels'||g_jobid_stmt,
sysdate,null,'DIMENSION','CREATE-TABLE','DUPALL000'||l_count||' '||g_job_id,'I');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'DUPALL000'||l_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'DUPALL000'||l_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'DUPALL000'||l_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'DUPALL000'||l_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'DUPALL000'||l_count||' '||g_job_id,'U');
if g_update_star_flag then
insert_into_load_progress_d(g_load_pk,g_dim_name,'Move Update Data into Hold Table'||g_jobid_stmt,
sysdate,null,'DIMENSION','CREATE-TABLE','CDVT2020'||l_count||' '||g_job_id,'I');
execute_hold_insert_stmt;
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CDVT2020'||l_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CDVT2020'||l_count||' '||g_job_id,'U');
execute_insert_update_star(l_count);
g_number_rows_processed:=g_number_rows_processed+g_number_rows_inserted;
write_to_log_file_n('Moved '||g_number_rows_inserted||' into star table');
if g_type_ilog_generation='UPDATE' then
if delete_gilog_status = false then --delete where status=1
return;
g_number_rows_processed,'PROCESSING','UPDATE')=false then
g_status_message:=EDW_OWB_COLLECTION_UTIL.g_status_message;
if g_update_star_flag then
if EDW_OWB_COLLECTION_UTIL.truncate_table(g_dim_name_hold) = false then
return;
l_stmt:='select 1 from '||g_dim_name||' where rownum=1';
function initial_insert_into_star(p_multi_thread boolean) return boolean is
Begin
if g_debug then
write_to_log_file_n('In initial_insert_into_star');
insert_into_load_progress_d(g_load_pk,g_dim_name,'Load ILOG'||g_jobid_stmt,sysdate,null,'DIMENSION',
'INSERT','IL2010'||g_job_id,'I');
insert_into_ilog(p_multi_thread);
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'IL2010'||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,g_dim_name,'Create Level Key Tables'||g_jobid_stmt,sysdate,null,'DIMENSION',
'CREATE-TABLE','IS2020'||g_job_id,'I');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'IS2020'||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'IS2020'||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'IS2020'||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'IS2020'||g_job_id,'U');
write_to_log_file_n('Error in initial_insert_into_star '||g_status_message);
PROCEDURE insert_into_star IS
l_stmt varchar2(32000);
l_insert_type varchar2(200);
write_to_log_file_n('In insert_into_star'||get_time);
l_insert_type:='MASS';
l_stmt:='insert into '||g_dim_name||' ( ';
l_stmt:='insert /*+ PARALLEL ('||g_dim_name||','||g_parallel||') */ into '||g_dim_name||' ( ';
l_stmt_row:='insert into '||g_dim_name||' ( ';
l_stmt:=l_stmt||' CREATION_DATE, LAST_UPDATE_DATE ) ';
l_stmt_row:=l_stmt_row||' CREATION_DATE, LAST_UPDATE_DATE ) ';
l_stmt:=l_stmt||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt||' '||g_where_stmt;
l_stmt_row:=l_stmt_row||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt||' '||g_where_stmt||' and '||
g_lowest_level_alias||'.rowid=:a';
l_stmt:=l_stmt||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt;
l_stmt_row:=l_stmt_row||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt||' where '||
g_lowest_level_alias||'.rowid=:a';
l_stmt:=l_stmt||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt||','||g_ilog_small||' '||g_where_stmt||
' And '||g_ilog_small||'.row_id='||g_lowest_level_alias||'.rowid';
l_stmt_row:=l_stmt_row||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt||' '||g_where_stmt||' and '||
g_lowest_level_alias||'.rowid=:a';
l_stmt:=l_stmt||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt||','||g_ilog_small||' where '||
g_ilog_small||'.row_id='||g_lowest_level_alias||'.rowid';
l_stmt_row:=l_stmt_row||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt||' where '||
g_lowest_level_alias||'.rowid=:a';
l_stmt:=l_stmt||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt||' '||g_where_stmt||
' and '||g_lowest_level_alias||'.rowid=:a';
l_stmt_row:=l_stmt_row||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt||' '||g_where_stmt||
' and '||g_lowest_level_alias||'.rowid=:a';
l_stmt:=l_stmt||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt||' '||g_where_stmt;
l_stmt_row:=l_stmt_row||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt||' '||g_where_stmt||
' and '||g_lowest_level_alias||'.rowid=:a';
l_stmt:=l_stmt||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt||' where '||
g_lowest_level_alias||'.rowid=:a';
l_stmt_row:=l_stmt_row||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt||' where '||
g_lowest_level_alias||'.rowid=:a';
l_stmt:=l_stmt||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt;
l_stmt_row:=l_stmt_row||g_select_stmt||',SYSDATE,SYSDATE '||g_from_stmt||' and '||
g_lowest_level_alias||'.rowid=:a';
if g_skip_ilog_update=false then
l_status:=set_gilog_status;
g_skip_ilog_update:=false;
insert_into_load_progress_d(g_load_pk,g_dim_name,'Insert into Star'||g_jobid_stmt,sysdate,null,'DIMENSION',
'INSERT','LIS2020'||l_count||' '||g_job_id,'I');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'LIS2020'||l_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'LIS2020'||l_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'LIS2020'||l_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'LIS2020'||l_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'LIS2020'||l_count||' '||g_job_id,'U');
write_to_log_file_n('Going to execute insert into star');
<>
if g_ltc_merge_use_nl or l_insert_type='ROW-BY-ROW' then
if g_debug then
write_to_log_file_n('nested loop option');
g_number_rows_inserted:=0;
l_stmt1:=l_stmt1||' as select rowid row_id from '||g_lowest_level;
l_stmt1:='select row_id from '||l_table;
g_number_rows_inserted:=g_number_rows_inserted+1;
write_to_log_file_n('Out of memory error in mass insert. (Try row-by-row) '||sqlerrm);
l_insert_type:='ROW-BY-ROW';
goto start_direct_insert;
goto start_direct_insert;
g_number_rows_inserted:=sql%rowcount;
g_number_rows_processed:=g_number_rows_processed+g_number_rows_inserted;
write_to_log_file_n('Moved '||g_number_rows_inserted||' into the star table '||get_time);
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'LIS2020'||l_count||' '||g_job_id,'U');
if g_type_ilog_generation='UPDATE' then
if delete_gilog_status=false then --delete where status=1
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'LIS2020'||l_count||' '||g_job_id,'U');
g_number_rows_processed,'PROCESSING','UPDATE')= false then
g_status_message:=EDW_OWB_COLLECTION_UTIL.g_status_message;
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'LIS2020'||l_count||' '||g_job_id,'U');
End;--PROCEDURE insert_into_star IS
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 return number is
l_stmt varchar2(10000);
if g_type_ilog_generation='UPDATE' then
if g_collection_size =0 then
l_stmt:='update '||g_ilog||' set status=1 ';
l_stmt:='update '||g_ilog||' set status=1 where rownum <='||g_collection_size;
write_to_log_file_n('Updated '||l_count||' rows in '||g_ilog||get_time);
l_stmt:=l_stmt||' as select row_id,'||g_ltc_pk||',decode(status,1,2,2,2,decode(sign(rownum-'||
g_collection_size||'),1,0,1)) status from (select row_id,'||g_ltc_pk||',status from '||g_ilog_prev||
' 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 '||g_ilog_prev||
' order by status) abc ';
l_stmt:=l_stmt||' as select row_id,'||g_ltc_pk||',decode(status,1,2,0,1,2) status from '||
g_ilog_prev;
l_stmt:=l_stmt||' as select row_id,decode(status,1,2,0,1,2) status from '||
g_ilog_prev;
function delete_gilog_status return boolean is
l_stmt varchar2(4000);
write_to_log_file_n('In delete_gilog_status');
l_stmt:='delete '||g_ilog||' where status=1';
write_to_log_file_n('Deleted '||sql%rowcount||' rows from '||g_ilog||get_time);
l_stmt:=l_stmt||' as select '||g_dim_user_pk||' from '||g_dim_name_temp_int;
l_stmt:=l_stmt||' as select /*+ORDERED USE_NL('||g_dim_name||')*/ ';
l_stmt:=l_stmt||' as select /*+ORDERED*/ ';
l_stmt:=l_stmt||' as select '||g_dim_user_pk||','||g_dim_pk;
if g_update_type='DELETE-INSERT' then
l_stmt:=l_stmt||',CREATION_DATE ';
l_stmt:=l_stmt||' as select '||g_dim_user_pk||','||g_dim_pk;
g_temp_int_tm_stmt:='insert into '||g_dim_name_temp||'( ';
if g_update_type='DELETE-INSERT' then
g_temp_int_tm_stmt:=g_temp_int_tm_stmt||g_dim_user_pk||','||g_dim_pk||
', row_id1, row_id3, operation_code1,CREATION_DATE,slow_flag) ';
g_temp_int_tm_stmt:=g_temp_int_tm_stmt||' select /*+ORDERED*/ ';
if g_update_type='DELETE-INSERT' then
g_temp_int_tm_stmt:=g_temp_int_tm_stmt||','||g_dim_name_with_slow||'.CREATION_DATE ';
if g_update_type='DELETE-INSERT' then
g_temp_int_tm_stmt:=g_temp_int_tm_stmt||','||g_dim_name_with_slow||'.CREATION_DATE ';
procedure make_hold_insert_stmt is
l_divide number:=2;
write_to_log_file_n('In make_hold_insert_stmt');
g_hold_insert_stmt:='create table '||g_dim_name_hold||' tablespace '||g_op_table_space;
g_hold_insert_stmt:=g_hold_insert_stmt||' storage (initial '||l_extent||' next '||
l_extent||' pctincrease 0 MAXEXTENTS 2147483645) ';
g_hold_insert_stmt:=g_hold_insert_stmt||' parallel (degree '||g_parallel||') ';
g_hold_insert_stmt:=g_hold_insert_stmt||' as ';
g_hold_insert_stmt:=g_hold_insert_stmt||g_select_stmt_nopk;
g_hold_insert_stmt:=g_hold_insert_stmt||',TM.'||g_dim_pk||',TM.'||g_dim_user_pk||',TM.ROW_ID1 row_id';
if g_update_type='DELETE-INSERT' then
g_hold_insert_stmt:=g_hold_insert_stmt||',TM.CREATION_DATE ';
g_hold_insert_stmt:=g_hold_insert_stmt||' '||g_from_stmt;
g_hold_insert_stmt:=g_hold_insert_stmt||','||g_dim_name_temp||' TM ';
g_hold_insert_stmt:=g_hold_insert_stmt||g_where_stmt||' And ';
g_hold_insert_stmt:=g_hold_insert_stmt||' where ';
g_hold_insert_stmt:=g_hold_insert_stmt||' TM.row_id3='||g_lowest_level_alias||'.ROWID';
g_hold_insert_stmt:=g_hold_insert_stmt||' And TM.operation_code1=1 ';
g_hold_insert_stmt_row:='insert into '||g_dim_name_hold||'(';
g_hold_insert_stmt_row:=g_hold_insert_stmt_row||g_insert_stmt_nopk;
g_hold_insert_stmt_row:=g_hold_insert_stmt_row||','||g_dim_pk||','||g_dim_user_pk||',row_id) ';
g_hold_insert_stmt_row:=g_hold_insert_stmt_row||g_select_stmt_nopk;
g_hold_insert_stmt_row:=g_hold_insert_stmt_row||','||g_dim_pk||','||g_dim_user_pk||',ROW_ID1';
g_hold_insert_stmt_row:=g_hold_insert_stmt_row||' '||g_from_stmt_hd_row;
g_hold_insert_stmt_row:=g_hold_insert_stmt_row||g_where_stmt||' and ';
g_hold_insert_stmt_row:=g_hold_insert_stmt_row||' where ';
g_hold_insert_stmt_row:=g_hold_insert_stmt_row||g_lowest_level_alias||'.rowid=:a';
write_to_log_file_n('g_hold_insert_stmt_row is '||g_hold_insert_stmt_row);
l_stmt:=l_stmt||' as select ';
if g_update_type='DELETE-INSERT' then
l_stmt:=l_stmt||','||g_dim_name||'.CREATION_DATE';
write_to_log_file_n('Inserted '||sql%rowcount||' rows into '||g_dim_name_temp||get_time);
we can boost performance by testing to see if there is updates or not
if there is no update then dont even bother to execute it
*/
if check_temp_table_for_status('UPDATE')=true then
g_update_star_flag:=true;
write_to_log_file_n('Star Update Needed');
g_update_star_flag:=false;
write_to_log_file_n('Star Update NOT Needed');
if check_temp_table_for_status('INSERT')=true then
g_insert_star_flag:=true;
write_to_log_file_n('Star Insert Needed');
g_insert_star_flag:=false;
write_to_log_file_n('Star Insert NOT Needed');
count_temp_table_records; --this prints out NOCOPY how many insert update etc
see if in the temp table there are any records with opeartion_code1 of update or insert
*/
function check_temp_table_for_status(p_status varchar2) return boolean is
l_stmt varchar2(2000);
if p_status='INSERT' then
l_status:=0;
elsif p_status='UPDATE' then
l_status:=1;
l_stmt:='select 1 from '||g_dim_name_temp||' where operation_code1=:a and rownum=1';
l_stmt:='select count(*), operation_code1 from '||g_dim_name_temp||' '||
' group by operation_code1 ';
select relation.sequence_name
from edw_pvt_sequences_md_v relation,
edw_pvt_map_properties_md_v map,
edw_pvt_map_properties_md_v map2,
edw_pvt_map_sources_md_v ru
where
map.primary_target=p_dim_id
and map2.primary_target=map.primary_source
and ru.mapping_id=map2.mapping_id
and ru.source_id=relation.sequence_id;
PROCEDURE make_insert_update_stmt_star IS
l_iv varchar2(400);
write_to_log_file_n('In make_insert_update_stmt_star '||get_time);
g_insert_stmt_star:='insert into '||g_dim_name||'( ';
g_insert_stmt_star:='insert /*+ PARALLEL ('||g_dim_name||','||g_parallel||') */ into '||g_dim_name||'( ';
g_insert_stmt_star_row:='insert into '||g_dim_name||'( ';
g_insert_stmt_star:=g_insert_stmt_star||' '||g_dim_col(i);
g_insert_stmt_star:=g_insert_stmt_star||','||g_dim_col(i);
g_insert_stmt_star:=g_insert_stmt_star||g_insert_stmt_nopk_ins;
g_insert_stmt_star:=g_insert_stmt_star||','||g_dim_pk||','||g_dim_user_pk;
g_insert_stmt_star:=g_insert_stmt_star||',CREATION_DATE,LAST_UPDATE_DATE) ';
g_insert_stmt_star:=g_insert_stmt_star||g_select_stmt_nopk_ins;
g_insert_stmt_star:=g_insert_stmt_star||',TM.'||g_dim_pk||',TM.'||g_dim_user_pk;
g_insert_stmt_star:=g_insert_stmt_star||',SYSDATE,SYSDATE ';
g_insert_stmt_star:=g_insert_stmt_star||' '||g_from_stmt_ins;
g_insert_stmt_star:=g_insert_stmt_star||','||g_dim_name_temp||' TM ';
g_insert_stmt_star:=g_insert_stmt_star||g_where_stmt_ins||' And ';
g_insert_stmt_star:=g_insert_stmt_star||' where ';
g_insert_stmt_star:=g_insert_stmt_star||' TM.row_id3='||g_lowest_level_alias||'.ROWID';
g_insert_stmt_star:=g_insert_stmt_star||' And TM.operation_code1=0 ';
g_insert_stmt_star_row:=g_insert_stmt_star_row||g_insert_stmt_nopk_ins;
g_insert_stmt_star_row:=g_insert_stmt_star_row||','||g_dim_pk||','||g_dim_user_pk;
g_insert_stmt_star_row:=g_insert_stmt_star_row||',CREATION_DATE,LAST_UPDATE_DATE) ';
g_insert_stmt_star_row:=g_insert_stmt_star_row||g_select_stmt_nopk_ins;
g_insert_stmt_star_row:=g_insert_stmt_star_row||','||g_dim_pk||','||g_dim_user_pk;
g_insert_stmt_star_row:=g_insert_stmt_star_row||',SYSDATE,SYSDATE ';
g_insert_stmt_star_row:=g_insert_stmt_star_row||' '||g_from_stmt_ins_row;
g_insert_stmt_star_row:=g_insert_stmt_star_row||g_where_stmt_ins||' And ';
g_insert_stmt_star_row:=g_insert_stmt_star_row||' where ';
g_insert_stmt_star_row:=g_insert_stmt_star_row||g_lowest_level_alias||'.rowid=:a';
if g_update_type='DELETE-INSERT' then
g_update_stmt_star:='insert into '||g_dim_name||' ( ';
g_update_stmt_star:=g_update_stmt_star||g_insert_stmt_nopk_ins;
g_update_stmt_star:=g_update_stmt_star||','||g_dim_pk||','||g_dim_user_pk;
g_update_stmt_star:=g_update_stmt_star||',CREATION_DATE,LAST_UPDATE_DATE';
g_update_stmt_star:=g_update_stmt_star||') select ';
g_update_stmt_star:=g_update_stmt_star||g_insert_stmt_nopk_ins;
g_update_stmt_star:=g_update_stmt_star||','||g_dim_pk||','||g_dim_user_pk;
g_update_stmt_star:=g_update_stmt_star||',CREATION_DATE,SYSDATE';
g_update_stmt_star:=g_update_stmt_star||' from '||g_dim_name_hold;
if g_update_type='ROW-BY-ROW' then
g_update_stmt_star:='update '||g_dim_name||' set ( ';
elsif g_update_type='MASS' then
if g_parallel is null then
g_update_stmt_star:='update /*+ ORDERED USE_NL('||g_dim_name||')*/ '||g_dim_name||' set ( ';
g_update_stmt_star:='update /*+ ORDERED USE_NL('||g_dim_name||')*/ /*+PARALLEL ('||g_dim_name||','||
g_parallel||')*/ '||g_dim_name||' set ( ';
g_update_stmt_star:=g_update_stmt_star||g_insert_stmt_nopk;
g_update_stmt_star:=g_update_stmt_star||','||g_dim_pk||','||g_dim_user_pk;
g_update_stmt_star:=g_update_stmt_star||',LAST_UPDATE_DATE) = ( select ';
g_update_stmt_star:=g_update_stmt_star||g_insert_stmt_nopk;
g_update_stmt_star:=g_update_stmt_star||','||g_dim_pk||','||g_dim_user_pk;
g_update_stmt_star:=g_update_stmt_star||',SYSDATE ';
g_update_stmt_star:=g_update_stmt_star||' from '||g_dim_name_hold||' where ';
if g_update_type='ROW-BY-ROW' then
g_update_stmt_star:=g_update_stmt_star||g_dim_name_hold||'.row_id=:a) where '||g_dim_name||'.rowid=:b ';
elsif g_update_type='MASS' then
g_update_stmt_star:=g_update_stmt_star||g_dim_name_hold||'.row_id='||g_dim_name||'.rowid) where '||
g_dim_name||'.rowid in (select row_id from '||g_dim_name_hold||')';
g_update_stmt_star_row:='update '||g_dim_name||' set ( '||
g_insert_stmt_nopk||','||g_dim_pk||','||g_dim_user_pk||',LAST_UPDATE_DATE) = ( select '||
g_insert_stmt_nopk||','||g_dim_pk||','||g_dim_user_pk||',SYSDATE '||' from '||g_dim_name_hold||' where '||
g_dim_name_hold||'.row_id=:a) where '||g_dim_name||'.rowid=:b ';
procedure execute_hold_insert_stmt is
l_stmt varchar2(5000);
write_to_log_file_n('In execute_hold_insert_stmt'||get_time);
if create_ltc_copy_low_hd_ins('UPDATE')=false then
return;
l_stmt:=l_stmt||' as select rowid row_id from '||g_levels_copy_low_hd_ins;
l_stmt:=l_stmt||' as select row_id3 row_id from '||g_dim_name_temp||
' where operation_code1=1';
l_stmt:='select row_id from '||l_table;
execute immediate g_hold_insert_stmt_row using l_rowid;
write_to_log_file_n('Inserted '||l_total_count||' rows into '||g_dim_name_hold||get_time);
execute immediate g_hold_insert_stmt;
write_to_log_file_n('Inserted '||g_count_dim_name_hold||' rows into '||g_dim_name_hold||get_time);
l_stmt:=l_stmt||'as select row_id from '||g_dim_name_hold;
function execute_update_stmt return number is
l_stmt varchar2(5000);
l_update_type varchar2(400);
write_to_log_file_n('In execute_update_stmt');
l_update_type:=g_update_type;
<>
if l_update_type='MASS' or l_update_type='DELETE-INSERT' then
--if create_dim_name_rowid_hold=false then
--return false;
having the rowid table seemed to slow down the update!
*/
null;
if l_update_type='ROW-BY-ROW' then
l_stmt:='select row_id from '||g_dim_name_hold;
execute immediate g_update_stmt_star_row using l_rowid(i),l_rowid(i);
execute immediate g_update_stmt_star_row using l_rowid(i),l_rowid(i);
elsif l_update_type='MASS' then
begin
if g_debug then
write_to_log_file_n('Going to execute g_update_stmt_star '||get_time);
execute immediate g_update_stmt_star;
write_to_log_file_n('Memory issue with Mass Update. Retrying using ROW_BY_ROW');
l_update_type:='ROW-BY-ROW';
goto start_update;
goto start_update;
write_to_log_file('Problem stmt '||g_update_stmt_star);
elsif l_update_type='DELETE-INSERT' then
--first delete
l_stmt:='delete '||g_dim_name||' where exists (select 1 from '||g_dim_name_hold||' where '||
g_dim_name_hold||'.row_id='||g_dim_name||'.rowid)';
write_to_log_file('Deleted '||sql%rowcount||' rows');
write_to_log_file_n('Going to execute g_update_stmt_star');
execute immediate g_update_stmt_star;
write_to_log_file('Inserted '||sql%rowcount||' rows');
write_to_log_file('Problem stmt '||g_update_stmt_star);
write_to_log_file_n('Updated '||l_total_count||' records In Star Table '||get_time);
PROCEDURE execute_insert_update_star(p_count number) IS
l_update_count number:=0;
write_to_log_file_n('In execute_insert_update_star '||get_time);
if g_insert_star_flag then
Begin
insert_into_load_progress_d(g_load_pk,g_dim_name,'Insert Into Star Table'||g_jobid_stmt,sysdate,null,
'DIMENSION','INSERT','CDVT2030'||p_count||' '||g_job_id,'I');
if execute_insert_stmt=false then
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CDVT2030'||p_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CDVT2030'||p_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CDVT2030'||p_count||' '||g_job_id,'U');
end if;--if g_insert_star_flag then
if g_update_star_flag then
--if the dim is a part of any derv/summary fact, log all needed cols before update
if g_derv_snp_change_flag then
insert_into_load_progress_d(g_load_pk,g_dim_name,'Log Before Update Data'||g_jobid_stmt,sysdate,null,
'DIMENSION','INSERT','LBUCDVT2040'||p_count||' '||g_job_id,'I');
if log_before_update_data=false then
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'LBUCDVT2040'||p_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'LBUCDVT2040'||p_count||' '||g_job_id,'U');
insert_into_load_progress_d(g_load_pk,g_dim_name,'Update Star Table'||g_jobid_stmt,sysdate,null,
'DIMENSION','INSERT','CDVT2040'||p_count||' '||g_job_id,'I');
l_update_count:=execute_update_stmt;--creates update prot table inside
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'CDVT2040'||p_count||' '||g_job_id,'U');
if l_update_count is null then
g_status:=false;
g_number_rows_inserted:=g_number_rows_inserted+l_update_count;
write_to_log_file_n('Finished execute_insert_update_star '||get_time);
function execute_insert_stmt return boolean is
l_stmt varchar2(4000);
l_insert_type varchar2(200);
write_to_log_file_n('In execute_insert_stmt '||get_time);
l_insert_type:='MASS';
<>
if g_ltc_merge_use_nl or l_insert_type='ROW-BY-ROW' then
l_unique_violation:=false;
write_to_log_file_n('ROW-BY-ROW INSERTS');
g_number_rows_inserted:=0;
if create_ltc_copy_low_hd_ins('INSERT')=false then
g_status:=false;
l_stmt:=l_stmt||' as select rowid row_id from '||g_levels_copy_low_hd_ins;
l_stmt:=l_stmt||' as select row_id3 row_id from '||g_dim_name_temp||
' where operation_code1=0';
l_stmt:='select row_id from '||l_table;
execute immediate g_insert_stmt_star_row using l_rowid;
g_number_rows_inserted:=g_number_rows_inserted+1;
write_to_log_file_n('going to execute g_insert_stmt_star ');
execute immediate g_insert_stmt_star;
g_number_rows_inserted:=sql%rowcount;
write_to_log_file_n('Out of memory error in mass insert. (Try row-by-row) '||sqlerrm||get_time);
l_insert_type:='ROW-BY-ROW';
goto start_insert;
goto start_insert;
goto start_insert;
write_to_log_file_n('Inserted '||g_number_rows_inserted||' rows'||get_time);
select upper(item.column_name),
replace(upper(item.column_name),'_KEY'), --for now assume this...
dim.dim_id
from edw_unique_keys_md_v pk,
edw_pvt_key_columns_md_v isu,
edw_pvt_columns_md_v item,
edw_dimensions_md_v dim
where pk.entity_id=dim.dim_id
and isu.key_id=pk.key_id
and isu.column_id=item.column_id
and pk.primarykey=1
and dim.dim_name=p_dim_name;
procedure make_select_from_where_stmt is
l_run integer:=0;
write_to_log_file_n('In make_select_from_where_stmt');
g_insert_stmt_nopk:=null;
g_insert_stmt_nopk:=g_insert_stmt_nopk||g_dim_col(i)||',';
if g_insert_stmt_nopk is not null then
g_insert_stmt_nopk:=substr(g_insert_stmt_nopk,1,length(g_insert_stmt_nopk)-1);
write_to_log_file_n('Insert stmt NOPK is '||g_insert_stmt_nopk);
g_select_stmt:=' select ';
g_select_stmt_nopk:=' select ';
g_select_stmt:=g_select_stmt||l_alias(i)||'.'||g_level_col(i)||' '||g_dim_col(i)||',';
g_select_stmt_nopk:=g_select_stmt_nopk||l_alias(i)||'.'||g_level_col(i)||' '||g_dim_col(i)||',';
g_select_stmt:=substr(g_select_stmt,1,length(g_select_stmt)-1);
g_select_stmt_nopk:=substr(g_select_stmt_nopk,1,length(g_select_stmt_nopk)-1);
write_to_log_file_n('select stmt is '||g_select_stmt);
write_to_log_file_n('select stmt NOPK is '||g_select_stmt_nopk);
g_where_snplog_stmt:=g_where_snplog_stmt||' '||'A_'||i||'.ROWID IN (select M_ROW$$ from '
||g_level_snapshot_logs(i)||') ';
g_where_snplog_stmt:=g_where_snplog_stmt||' Or '||'A_'||i||'.ROWID IN (select M_ROW$$ from '
||g_level_snapshot_logs(i)||') ';
procedure make_select_from_where_ins is
l_run integer:=0;
write_to_log_file_n('In make_select_from_where_ins');
g_insert_stmt_nopk_ins:=null;
g_insert_stmt_nopk_ins:=g_insert_stmt_nopk_ins||g_dim_col(i)||',';
if g_insert_stmt_nopk_ins is not null then
g_insert_stmt_nopk_ins:=substr(g_insert_stmt_nopk_ins,1,length(g_insert_stmt_nopk_ins)-1);
write_to_log_file_n('Insert stmt NOPK is '||g_insert_stmt_nopk_ins);
g_select_stmt_ins:=' select ';
g_select_stmt_nopk_ins:=' select ';
g_select_stmt_ins:=g_select_stmt_ins||l_alias(i)||'.'||g_level_col(i)||' '||g_dim_col(i)||',';
g_select_stmt_nopk_ins:=g_select_stmt_nopk_ins||l_alias(i)||'.'||g_level_col(i)||' '||g_dim_col(i)||',';
g_select_stmt_ins:=substr(g_select_stmt_ins,1,length(g_select_stmt_ins)-1);
g_select_stmt_nopk_ins:=substr(g_select_stmt_nopk_ins,1,length(g_select_stmt_nopk_ins)-1);
write_to_log_file_n('select stmt is '||g_select_stmt_ins);
write_to_log_file_n('select stmt NOPK is '||g_select_stmt_nopk_ins);
l_stmt:=l_stmt||' as select rowid row_id,';
l_stmt:='insert into '||p_ilog_temp||' (row_id) select ';
l_stmt:=l_stmt||' as select ';
l_stmt:=l_stmt||' as select ';
l_stmt:=l_stmt||' as select rowid row_id ';
l_stmt:='insert into '||g_snplogs_L(i)||'(row_id,'||g_ltc_pk||')';
l_stmt:='insert into '||g_snplogs_L(i)||'(row_id)';
l_stmt:=l_stmt||' as select ';
l_stmt:=l_stmt||' as select ';
write_to_log_file_n('Inserted into '||g_snplogs_L(i)||' '||sql%rowcount||' rows '||get_time);
l_stmt:=l_stmt||' as select rowid row_id ';
insert the rowids of the child level into the LT table for the child for all the changed records of the parent
p_mode=DOWN means we are drilling down. for changes to parent, we are finding change to child
p_mode=UP means we are drilling up. for changes to child, we are finding changes to parent
*/
function insert_into_LT(p_child_level varchar2, p_parent_level varchar2,p_mode varchar2) return boolean is
l_stmt varchar2(10000);
write_to_log_file_n('In insert_into_LT');
l_stmt:=l_stmt||' as select /*+ORDERED ';
l_stmt:=l_stmt||' as select /*+ORDERED ';
create table BIS.EDW_TRD_PARTNER_A_LTCLF parallel (degree 3) as select distinct
A1.PARENT_TPARTNER_FK_KEY from BIS.EDW_TPRT_P4_TPARTNER_LTCI A1,
BIS.EDW_TPRT_P4_TPARTNER_LTCL Y where A1.row_id=Y.row_id oo01/29/2001 16:47:30
was stuck forever. all the tables have only 1 row! if we remove the parallel (degree 3)
statement, its very fast!! is this a database bug?
*/
if l_fk_table_count >= 100 then
l_stmt:=l_stmt||' parallel (degree '||g_parallel||') ';
l_stmt:=l_stmt||' as select /*+ORDERED ';
l_stmt:=l_stmt||' as select row_id from '||g_snplogs_LT(l_child_index)||
' MINUS select row_id from '||g_snplogs_L(l_child_index);
l_stmt:='insert into '||g_snplogs_L(l_child_index)||'(row_id,'||g_ltc_pk||') select A.row_id,A.'||g_ltc_pk||
' from '||l_snplogs_L||' B,'||g_snplogs_LT(l_child_index)||' A where A.row_id=B.row_id';
l_stmt:='insert into '||g_snplogs_L(l_child_index)||'(row_id) select row_id from '||l_snplogs_L;
write_to_log_file_n('Inserted '||sql%rowcount||' rows into '||g_snplogs_L(l_child_index)||get_time);
if insert_into_LT(p_level,g_levels(l_parent_index),'DOWN')=false then
return false;
if insert_into_LT(p_level,g_levels(l_parent_index),'UP')=false then
return false;
after inserting into the L table, insert these rows into the ILOG table
we cannot drop and recreate ilog so we can support error recovery
*/
function insert_into_ilog_from_L(p_multi_thread boolean) return boolean is
l_stmt varchar2(10000);
write_to_log_file_n('In insert_into_ilog_from_L');
l_stmt:=l_stmt||' as select ';
g_skip_ilog_update:=true;
g_skip_ilog_update:=false;
l_stmt:=l_stmt||' as select /*+ORDERED*/ A.'||g_ltc_pk||',A.rowid row_id,B.status from '||
g_ilog||' B,'||g_lowest_level_global||' A where A.'||g_ltc_pk||'=B.'||g_ltc_pk;
l_stmt:=l_stmt||' as select /*+ORDERED*/ B.row_id,B.status from '||
g_ilog||' B,'||g_lowest_level_global||' A where A.rowid=B.row_id';
l_stmt:=l_stmt||' as select row_id,'||g_ltc_pk||',0 status from '||g_snplogs_L(l_index)||
' MINUS select row_id,'||g_ltc_pk||',0 status from '||g_ilog;
l_stmt:=l_stmt||' as select row_id,0 status from '||g_snplogs_L(l_index)||
' MINUS select row_id,0 status from '||g_ilog;
l_stmt:='insert into '||g_ilog||'(row_id,'||g_ltc_pk||',status) select row_id,'||g_ltc_pk||
',status from '||l_ilog;
l_stmt:='insert into '||g_ilog||'(row_id, status) select row_id,status from '||l_ilog;
write_to_log_file_n('Inserted '||sql%rowcount||' rows into '||g_ilog||get_time);
l_stmt:=l_stmt||' as select row_id from '||g_ilog||' where status=1';
l_stmt:=l_stmt||' as select rowid row_id from '||g_levels(i)||' where 1=2';
l_stmt:=l_stmt||' as select /*+ORDERED USE_NL('||g_levels(i)||')*/ ';
l_stmt:=l_stmt||' as select /*+ORDERED*/ ';
if insert_into_ilog_from_L(p_multi_thread)=false then
return false;
/*recreate the from stmt and change the g_lowest_level and insert the new row_id into g_ilog*/
function recreate_from_stmt return boolean is
l_index number;
g_from_stmt_ins:=substr(g_from_stmt_ins,1,length(g_from_stmt_ins)-1);--for insert stmt
g_from_stmt_ins_row:=substr(g_from_stmt_ins_row,1,length(g_from_stmt_ins_row)-1);--for insert stmt row by row
procedure insert_into_ilog(p_multi_thread boolean) is
l_stmt varchar2(30000);
write_to_log_file_n('In insert_into_ilog');
if multi threading is true, we cannot make g_skip_ilog_update=true unless g_collection_size=0
*/
if p_multi_thread=false or g_collection_size=0 then
g_skip_ilog_update:=true;
g_skip_ilog_update:=false;
'as select /*+PARALLEL('||g_lowest_level||','||g_parallel||')*/ ';
'as select ';
if insert_L_ilog_parallel_dd(p_multi_thread)=false then
l_drill_down:=true;
Procedure make_temp_insert_sql IS
Begin
if g_debug then
write_to_log_file_n('In make_temp_insert_sql'||get_time);
g_temp_insert_stmt:='insert into '||g_dim_name_temp_int||' ( ';
g_temp_insert_stmt:=g_temp_insert_stmt||g_dim_pk||','||g_dim_user_pk||', row_id3 ';
g_temp_insert_stmt:=g_temp_insert_stmt||','||g_slow_cols(i);
g_temp_insert_stmt:=g_temp_insert_stmt||') select '||g_lowest_level_alias||'.'||g_ltc_pk||','
||g_lowest_level_alias||'.'||g_ltc_user_pk||','||g_lowest_level_alias||'.ROWID ';
g_temp_insert_stmt:=g_temp_insert_stmt||','||g_slow_level_alias(i)||'.'||g_slow_level_col(i);
g_temp_insert_stmt:=g_temp_insert_stmt||g_from_stmt||' '||g_where_stmt;
g_temp_insert_stmt:=g_temp_insert_stmt||g_from_stmt;
g_temp_insert_stmt:=g_temp_insert_stmt||' from '||g_lowest_level||' '||g_lowest_level_alias;
g_temp_insert_stmt:=g_temp_insert_stmt||') select '||g_lowest_level_alias||'.'||g_ltc_pk||','
||g_lowest_level_alias||'.'||g_ltc_user_pk||','||g_lowest_level_alias||'.ROWID ';
g_temp_insert_stmt:=g_temp_insert_stmt||','||g_slow_level_alias(i)||'.'||g_slow_level_col(i);
g_temp_insert_stmt:=g_temp_insert_stmt||g_from_stmt||','||g_ilog||' '||g_where_stmt||' And ';
g_temp_insert_stmt:=g_temp_insert_stmt||g_from_stmt||','||g_ilog||' where ';
g_temp_insert_stmt:=g_temp_insert_stmt||g_ilog||'.row_id='||
g_lowest_level_alias||'.rowid and '||g_ilog||'.status=1';
g_temp_insert_stmt:=g_temp_insert_stmt||' from '||g_lowest_level||' '||g_lowest_level_alias||','||g_ilog;
g_temp_insert_stmt:=g_temp_insert_stmt||' where '||g_lowest_level_alias||'.rowid='||
g_ilog||'.row_id and '||g_ilog||'.status=1';
End;--Procedure make_temp_insert_sql
Procedure execute_temp_insert_sql IS
l_count number;
write_to_log_file_n('In execute_temp_insert_sql');
write_to_log_file_n('Going to execute g_temp_insert_sql, inserting into table '||g_dim_name_temp_int);
execute immediate g_temp_insert_stmt;
write_to_log_file_n('Inserted '||l_count||' records into '||g_dim_name_temp_int||get_time);
write_to_log_file_n('In execute_temp_insert_sql exec flag found false');
write_to_log_file_n('Problem statement '||g_temp_insert_stmt);
End;--Procedure execute_temp_insert_sql
l_stmt:='select nvl(sum(number_processed),0) from edw_coll_progress_log where object_name=:a and object_type=:b '||
' and status=:c';
g_insert_prot_table:=g_bis_owner||'.'||l_dim_name_org||'IP';--global only with slow change
g_insert_prot_table_active:=g_bis_owner||'.'||l_dim_name_org||'IPA';--used in this session
g_before_update_table_name:=g_bis_owner||'.'||l_dim_name_org||'BU';
g_number_before_update_table:=1;
g_bu_insert_prot_table:=g_bis_owner||'.'||l_dim_name_org||'BP';--global. used for derv fact sync
g_bu_insert_prot_table_active:=g_bis_owner||'.'||l_dim_name_org||'BPA';--global. used for derv fact sync
g_insert_stmt_star:=null;
g_update_stmt_star:=null;
g_number_rows_inserted :=0;
g_number_rows_updated :=0;
g_before_update_load_pk:=0;
g_skip_ilog_update:=false;
function get_number_rows_inserted return number is
begin
return g_number_rows_inserted;
End;--function get_number_rows_inserted return number is
function get_number_rows_updated return number is
begin
return g_number_rows_updated;
End;--function get_number_rows_updated return number is
procedure insert_into_load_progress(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
EDW_OWB_COLLECTION_UTIL.insert_into_load_progress(p_load_fk,p_object_name,g_dim_id,p_load_progress,p_start_date,
p_end_date,p_category,p_operation,p_seq_id,p_flag,1000);
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_dim_id,p_load_progress,p_start_date,
p_end_date,p_category,p_operation,p_seq_id,p_flag,1000);
if g_before_update_table_final is not null then
if EDW_OWB_COLLECTION_UTIL.check_table(g_before_update_table_final) then
EDW_OWB_COLLECTION_UTIL.analyze_table_stats(substr(g_before_update_table_final,
instr(g_before_update_table_final,'.')+1,length(g_before_update_table_final)),
substr(g_before_update_table_final,1,instr(g_before_update_table_final,'.')-1),1);
insert_into_load_progress_d(g_load_pk,g_dim_name,'Analyze Star Table'||g_jobid_stmt,sysdate,null,'DIMENSION',
'ANALYZE','AN2200'||g_job_id,'I');
insert_into_load_progress_d(g_load_pk,null,null,null,sysdate,null,null,'AN2200'||g_job_id,'U');
l_stmt:='select text from edw_pvt_map_properties_md_v where mapping_id=:a and text_type=''Filter''';
function get_before_update_table_name return boolean is
Begin
g_number_before_update_table:=1;
g_before_update_table(g_number_before_update_table):=g_before_update_table_name||g_number_before_update_table;
if EDW_OWB_COLLECTION_UTIL.check_table(g_before_update_table(g_number_before_update_table))=false then
g_before_update_table_final:=g_before_update_table(g_number_before_update_table);
g_number_before_update_table:=g_number_before_update_table+1;
write_to_log_file_n('Error in get_before_update_table_name '||g_status_message);
log_before_update_data is called in each loop. we will analyze the table in the very end
*/
function log_before_update_data return boolean is
l_stmt varchar2(32000);
write_to_log_file_n('In log_before_update_data'||get_time);
for every run of the load, the update data goes into a new table
*/
if EDW_OWB_COLLECTION_UTIL.check_table(g_before_update_table_final)=false then
if create_before_update_table=false then
return false;
l_stmt:='insert into '||g_before_update_table_final||'('||g_dim_pk||','||g_dim_user_pk;
l_stmt:=l_stmt||',LAST_UPDATE_DATE) select /*+ORDERED USE_NL('||g_dim_name||')*/ '; --use nl?
' and '||g_dim_name_hold||'.'||g_dim_pk||' not in (select '||g_dim_pk||' from '||g_bu_insert_prot_table_active||')';
write_to_log_file_n('Inserted '||sql%rowcount||' rows into '||
g_before_update_table_final||get_time);
if log_pk_into_bu_insert_prot=false then
return false;
function create_before_update_table return boolean is
l_stmt varchar2(10000);
l_stmt:='create table '||g_before_update_table_final||' tablespace '||g_op_table_space||
' storage (initial '||l_next_extent||' next '||l_next_extent||' pctincrease 0 MAXEXTENTS 2147483645) ';
l_stmt:=l_stmt||' as select '||g_dim_pk||','||g_dim_user_pk;
l_stmt:=l_stmt||',LAST_UPDATE_DATE from '||g_dim_name||' where 1=2';
write_to_log_file_n('Error creating '||g_before_update_table_final||' '||sqlerrm||get_time);
write_to_log_file('This table '||g_before_update_table_final||' already exists! '||
'Some other thread created it!');
l_stmt:='create unique index '||g_before_update_table_final||'u on '||
g_before_update_table_final||'('||g_dim_pk||') tablespace '||g_op_table_space;
l_stmt:='select level_name||''_LTC'' from edw_levels_md_v where level_prefix=:a and dim_id=:b';
g_stmt:=g_stmt||' as select '||g_dim_pk||' from '||g_dim_name||' where 1=2';
g_stmt:=g_stmt||' as select * from '||p_table;
if EDW_OWB_COLLECTION_UTIL.check_table(g_before_update_table_name||l_count) then
if EDW_OWB_COLLECTION_UTIL.drop_table(g_before_update_table_name||l_count)=false then
null;
if drop_prot_table(g_insert_prot_table,g_insert_prot_table_active)=false then
null;
if drop_prot_table(g_bu_insert_prot_table,g_bu_insert_prot_table_active)=false then
null;
l_stmt:=l_stmt||' as select row_id from '||g_ilog||' where status=1';
' as select rowid row_id, 1 status from dual ';
g_skip_ilog_update:=true;
g_type_ilog_generation:='UPDATE';
l_flag:=EDW_OWB_COLLECTION_UTIL.get_join_nl(l_size,l_avg_row_len,g_ok_switch_update);
if p_mode='INSERT' then
l_mode:=0;
elsif p_mode='UPDATE' then
l_mode:=1;
l_stmt:=l_stmt||' as select A.*,B.'||g_dim_pk||',B.'||g_dim_user_pk||',B.ROW_ID1 row_id1 from '||
g_lowest_level||' A,'||g_dim_name_temp||' B where A.rowid=B.row_id3 and B.operation_code1='||l_mode;
write_to_log_file_n('Goin to execute '||g_hold_insert_stmt||' and 1=2');
execute immediate g_hold_insert_stmt||' and 1=2';
l_stmt:=l_stmt||' as select '||g_dim_pk||' from '||g_dim_name_temp||
' where operation_code1=0';
l_stmt:=l_stmt||' as select ';
l_stmt:='update /*+ordered use_nl(AA)*/ '||g_dim_name_temp||' AA set(row_id1,operation_code1)=(select row_id,'||
'1 from '||l_table2||' where '||l_table2||'.'||g_dim_pk||'=AA.'||g_dim_pk||') where AA.'||g_dim_pk||
' in (select '||g_dim_pk||' from '||l_table2||') ';
write_to_log_file_n('Updated '||sql%rowcount||' rows '||get_time);
if l_percentage
write_to_log_file_n('g_type_ok_generation made UPDATE');
function log_pk_into_insert_prot return boolean is
Begin
if g_debug then
write_to_log_file_n('In log_pk_into_insert_prot');
g_stmt:='insert into '||g_insert_prot_table||'('||g_dim_pk||') select '||g_dim_pk||
' from '||g_dim_name_temp||' where slow_flag=1';
write_to_log_file_n('Inserted '||sql%rowcount||' rows '||get_time);
write_to_log_file_n('Error in log_pk_into_insert_prot '||g_status_message);
function log_pk_into_bu_insert_prot return boolean is
Begin
if g_debug then
write_to_log_file_n('In log_pk_into_bu_insert_prot');
g_stmt:='insert into '||g_bu_insert_prot_table||'('||g_dim_pk||') select '||g_dim_pk||
' from '||g_dim_name_hold;
write_to_log_file_n('Inserted '||sql%rowcount||' rows '||get_time);
write_to_log_file_n('Error in log_pk_into_bu_insert_prot '||g_status_message);
l_skip_ilog_update varchar2(2);
g_stmt:='select '||
'conc_id,'||
'conc_name,'||
'debug,'||
'exec_flag,'||
'bis_owner,'||
'parallel,'||
'collection_size,'||
'table_owner,'||
'forall_size,'||
'update_type,'||
'load_pk,'||
'fresh_restart,'||
'op_table_space,'||
'rollback,'||
'ltc_merge_use_nl,'||
'dim_inc_refresh_derv,'||
'check_fk_change,'||
'ok_switch_update,'||
'join_nl_percentage,'||
'max_threads,'||
'min_job_load_size,'||
'sleep_time,'||
'job_status_table,'||
'hash_area_size,'||
'sort_area_size,'||
'trace,'||
'read_cfig_options,'||
'ilog_table ,'||
'skip_ilog_update,'||
'level_change,'||
'dim_empty_flag,'||
'before_update_table_final,'||
'error_rec_flag,'||
'max_fk_density'||
' from '||p_table_name;
g_update_type,
g_load_pk,
l_fresh_restart,
g_op_table_space,
g_rollback,
l_ltc_merge_use_nl,
l_dim_inc_refresh_derv,
l_check_fk_change,
g_ok_switch_update,
g_join_nl_percentage,
g_max_threads,
g_min_job_load_size,
g_sleep_time,
g_job_status_table,
g_hash_area_size,
g_sort_area_size,
l_trace,
l_read_cfig_options,
g_ilog_main_name,
l_skip_ilog_update,
l_level_change,
l_dim_empty_flag,
g_before_update_table_final,
l_error_rec_flag,
g_max_fk_density;
write_to_log_file('g_update_type='||g_update_type);
write_to_log_file('g_ok_switch_update='||g_ok_switch_update);
write_to_log_file('l_skip_ilog_update='||l_skip_ilog_update);
write_to_log_file('g_before_update_table_final='||g_before_update_table_final);
g_skip_ilog_update:=false;
if l_skip_ilog_update='Y' then
g_skip_ilog_update:=true;
g_stmt:='select '||
'levels,'||
'child_level_number,'||
'level_snapshot_logs,'||
'level_order,'||
'consider_snapshot,'||
'levels_I, '||
'use_ltc_ilog '||
' from '||l_level_table||' order by level_number';
g_stmt:='select '||
'child_levels,'||
'child_fk,'||
'parent_pk'||
' from '||l_level_child_table||' order by run_number';
g_stmt:='select '||
'skip_cols'||
' from '||l_skip_table;
g_skip_ilog_update:=true;
function insert_L_ilog_parallel_dd(p_multi_thread boolean) return boolean is
--
l_status edw_owb_collection_util.varcharTableType;
write_to_log_file_n('In insert_L_ilog_parallel_dd'||get_time);
if insert_into_ilog_from_L(p_multi_thread)=false then
return false;
write_to_log_file_n('Error in insert_L_ilog_parallel_dd '||g_status_message);