The following lines contain the word 'select', 'insert', 'update' or 'delete':
g_load_mode is BU-DELETE when inc dim changes are propogated to derived/summary facts
In initial_set_up g_ilog and g_dlog will change names
*/
if initial_set_up(
p_input_table,
g_max_threads,
l_ilog_table,
l_dlog_table)=false then
return false;
if EDW_OWB_COLLECTION_UTIL.update_derv_fact_input_table(
p_input_table,
l_ilog_table,--the g_ilog_name
l_dlog_table, --the g_dlog_name
g_skip_ilog_update,
g_skip_dlog_update,
g_skip_ilog,
g_load_mode,
g_full_refresh,
g_src_object_ilog,
g_src_object_dlog,
g_src_snplog_has_pk,
g_err_rec_flag,
g_err_rec_flag_d
)=false then
return false;
if EDW_OWB_COLLECTION_UTIL.update_inp_table_jobid(p_input_table,l_job_id(l_number_jobs))=false then
return false;
if EDW_OWB_COLLECTION_UTIL.update_inp_table_jobid(p_input_table,l_job_id(l_number_jobs))=false then
return false;
if EDW_OWB_COLLECTION_UTIL.update_inp_table_jobid(p_input_table,l_job_id(l_number_jobs))=false then
return false;
if EDW_OWB_COLLECTION_UTIL.update_inp_table_jobid(p_input_table,l_job_id(l_number_jobs))=false then
return false;
if EDW_OWB_COLLECTION_UTIL.update_inp_table_jobid(p_input_table,l_job_id(l_number_jobs))=false then
return false;
if EDW_OWB_COLLECTION_UTIL.update_inp_table_jobid(p_input_table,l_job_id(l_number_jobs))=false then
return false;
g_skip_ilog_update:=false;
g_skip_dlog_update:=false;
insert_into_load_progress_d(g_load_fk,g_fact_name,'ILOG DLOG Processing'||g_jobid_stmt,sysdate,null,'DF',
'INSERT','ILOGPROC'||g_jobid_stmt,'I');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'ILOGPROC'||g_jobid_stmt,'U');
if EDW_OWB_COLLECTION_UTIL.drop_prot_tables(g_insert_prot_log,'PI',g_bis_owner)=false then
return false;
if EDW_OWB_COLLECTION_UTIL.drop_prot_tables(g_update_prot_log,'PU',g_bis_owner)=false then
return false;
if EDW_OWB_COLLECTION_UTIL.drop_prot_tables(g_delete_prot_log,'PD',g_bis_owner)=false then
return false;
insert_into_load_progress_d(g_load_fk,g_fact_name,'Recover from any Previous Error'||g_jobid_stmt,sysdate,null,'DF',
'RECOVER','DFRPE'||g_jobid_stmt,'I');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFRPE'||g_jobid_stmt,'U');
elsif g_load_mode='BU-DELETE' then
if g_collection_size=0 then
g_skip_ilog:=true;
elsif g_load_mode='BU-UPDATE' then
if g_collection_size=0 then
g_skip_ilog:=true;
if g_err_rec_flag and g_full_refresh = false and g_load_mode <>'BU-DELETE' and g_load_mode <>'BU-UPDATE' then
insert_into_load_progress_d(g_load_fk,g_fact_name,'Error Recovery into ILOG,DLOG'||g_jobid_stmt,sysdate,null,'DF',
'INSERT','ERRECDI'||g_jobid_stmt,'I');
if load_new_update_data= false then
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'ERRECDI'||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'ERRECDI'||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,g_fact_name,'Move Data into ILOG'||g_jobid_stmt,sysdate,null,'DF',
'INSERT','DFILOG'||g_jobid_stmt,'I');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFILOG'||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFILOG'||g_jobid_stmt,'U');
g_type_ilog_generation:='UPDATE';
g_type_dlog_generation:='UPDATE';
if g_load_mode <>'BU-DELETE' and g_load_mode <>'BU-UPDATE' then
if g_src_object_dlog is not null and g_full_refresh = false then
insert_into_load_progress_d(g_load_fk,g_fact_name,'Move Data into DLOG'||g_jobid_stmt,sysdate,null,'DF',
'INSERT','DFDLOG'||g_jobid_stmt,'I');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFDLOG'||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFDLOG'||g_jobid_stmt,'U');
g_type_dlog_generation:='UPDATE';
insert_into_load_progress_d(g_load_fk,g_fact_name,'Read Metadata'||g_jobid_stmt,sysdate,null,'DF',
'METADAT','DFRM'||g_jobid_stmt,'I');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFRM'||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFRM'||g_jobid_stmt,'U');
p_update_type varchar2,
p_fact_dlog varchar2,
p_skip_cols EDW_OWB_COLLECTION_UTIL.varcharTableType,
p_number_skip_cols number,
p_load_fk number,
p_fresh_restart boolean,
p_op_table_space varchar2,
p_bu_tables EDW_OWB_COLLECTION_UTIL.varcharTableType,--before update tables.prop dim change to derv
p_bu_dimensions EDW_OWB_COLLECTION_UTIL.varcharTableType,
p_number_bu_tables number,
p_bu_src_fact varchar2,--what table to look at as the src fact. if null, scan full the src fact
p_load_mode varchar2,
p_rollback varchar2,
p_src_join_nl_percentage number,
p_pre_hook varchar2,
p_post_hook varchar2
) return boolean is
Begin
g_fact_name:=p_fact_name;
g_update_type :=p_update_type;
g_load_mode is BU-DELETE when inc dim changes are propogated to derived/summary facts
*/
write_to_log_file_n('In EDW_DERIVED_FACT_FACT_COLLECT.COLLECT_FACT'||get_time);
write_to_log_file_n('Delete Tables Done');
if update_rowid_table_stmt = false then
write_to_log_file_n('update_rowid_table_stmt returned with error');
if delete_rowid_table_stmt = false then
write_to_log_file_n('delete_rowid_table_stmt returned with error');
if insert_rowid_table_stmt = false then
write_to_log_file_n('insert_rowid_table_stmt returned with error');
if make_insert_into_fact = false then --make the stmt
write_to_log_file_n('make_insert_into_fact_iv returned with error');
if make_update_into_fact = false then --make the stmt
write_to_log_file_n('make_update_into_fact returned with error');
if make_delete_into_fact = false then --make the stmt
write_to_log_file_n('make_delete_into_fact returned with error');
if g_load_mode<>'BU-DELETE' then
if g_debug then
write_to_log_file_n('In update mode. derv fact getting added');
g_total_insert:=0;
g_total_update:=0;
g_total_delete:=0;
if g_skip_ilog_update=false then
l_status:=set_gilog_status;
g_skip_ilog_update:=false;
g_skip_ilog_update:=false;
insert_into_load_progress_d(g_load_fk,g_fact_name,'Move Data into Temp'||g_jobid_stmt,sysdate,null,'DF',
'INSERT','DFTEMP'||l_count||g_jobid_stmt,'I');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFTEMP'||l_count||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFTEMP'||l_count||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,g_fact_name,'Summarize Base Fact Data'||g_jobid_stmt,sysdate,null,'DF',
'CREATE-TABLE','DFSUM'||l_count||g_jobid_stmt,'I');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFSUM'||l_count||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFSUM'||l_count||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,g_fact_name,'Create Update/Insert rowid Tables'||g_jobid_stmt,sysdate,null,'DF',
'CREATE-TABLE','DFROWID'||l_count||g_jobid_stmt,'I');
if execute_data_into_rowid_table = false then --creates update and insert rowid tables as select
write_to_log_file_n('execute_data_into_rowid_table returned with error');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFROWID'||l_count||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFROWID'||l_count||g_jobid_stmt,'U');
insert_into_temp_log('+');
if g_type_ilog_generation='UPDATE' then
if update_ilog_status_2 = false then
return false;
end if;--if g_load_mode<>'BU-DELETE' then
if g_load_mode='BU-DELETE' or (g_full_refresh=false and g_src_object_dlog is not null and
g_load_mode<>'BU-UPDATE') then
if g_debug then
write_to_log_file_n('In delete mode. derv fact getting subtracted');
g_total_insert:=0;
g_total_update:=0;
g_total_delete:=0;
if g_skip_dlog_update=false then
l_status:=set_gdlog_status;
g_skip_dlog_update:=false;
g_skip_dlog_update:=false;
insert_into_load_progress_d(g_load_fk,g_fact_name,'Move Update/Delete Data into Temp'||g_jobid_stmt,sysdate,null,'DF',
'INSERT','DFDTEMP'||l_count||g_jobid_stmt,'I');
l_status:=execute_delete_data_into_temp;
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFDTEMP'||l_count||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFDTEMP'||l_count||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,g_fact_name,'Summarize Base Fact Data'||g_jobid_stmt,sysdate,null,'DF',
'CREATE-TABLE','DFDSUM'||l_count||g_jobid_stmt,'I');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFDSUM'||l_count||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFDSUM'||l_count||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,g_fact_name,'Create Delete rowid Tables'||g_jobid_stmt,sysdate,null,'DF',
'CREATE-TABLE','DFDROWID'||l_count||g_jobid_stmt,'I');
if execute_ddata_into_rowid_table = false then --moves data into delete
write_to_log_file_n('execute_ddata_into_rowid_table returned with error');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFDROWID'||l_count||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFDROWID'||l_count||g_jobid_stmt,'U');
insert_into_temp_log('-');
if g_type_dlog_generation='UPDATE' then
if update_dlog_status_2 = false then
return false;
if EDW_OWB_COLLECTION_UTIL.does_table_have_data(g_delete_rowid_table) = 2 then
insert_into_load_progress_d(g_load_fk,g_fact_name,'Update Derived/Summary Fact with Delete Data'||g_jobid_stmt,sysdate,
null,'DF','UPDATE','DFDDEL'||p_count||g_jobid_stmt,'I');
if delete_into_fact = false then
write_to_log_file_n('delete_into_fact returned with false');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFDDEL'||p_count||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFDDEL'||p_count||g_jobid_stmt,'U');
if EDW_OWB_COLLECTION_UTIL.does_table_have_data(g_insert_rowid_table)=2 then
insert_into_load_progress_d(g_load_fk,g_fact_name,'Insert Into Derived/Summary Fact'||g_jobid_stmt,sysdate,null,'DF',
'INSERT','DFDINS'||p_count||g_jobid_stmt,'I');
if insert_into_fact = false then
write_to_log_file_n('insert_into_fact returned with false');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFDINS'||p_count||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFDINS'||p_count||g_jobid_stmt,'U');
if drop_insert_lock_table=false then
return false;
if EDW_OWB_COLLECTION_UTIL.does_table_have_data(g_update_rowid_table) =2 then
insert_into_load_progress_d(g_load_fk,g_fact_name,'Update Derived/Summary Fact'||g_jobid_stmt,sysdate,null,'DF',
'UPDATE','DFDUPD'||p_count||g_jobid_stmt,'I');
if update_into_fact = false then
write_to_log_file_n('update_into_fact returned with false');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFDUPD'||p_count||g_jobid_stmt,'U');
insert_into_load_progress_d(g_load_fk,null,null,null,sysdate,null,null,'DFDUPD'||p_count||g_jobid_stmt,'U');
l_stmt:='insert into '||p_ilog_temp||' (row_id,'||g_src_pk||') select ';
l_stmt:='insert into '||p_ilog_temp||' (row_id) select ';
g_skip_ilog_update:=true;
l_stmt:=l_stmt||' as select ';
l_stmt1:=l_stmt1||' as select ';
l_stmt:=l_stmt||' as select /*+ORDERED ';
l_stmt:=l_stmt||' as select /*+PARALLEL ('||g_src_object_ilog||','||g_parallel||')*/ '||
' distinct chartorowid(m_row$$) row_id,'||g_src_pk||',0 status from '||g_src_object_ilog||
' MINUS select row_id row_id,'||g_src_pk||',0 status from '||g_ilog;
l_stmt:=l_stmt||' as select /*+PARALLEL ('||g_src_object_ilog||','||g_parallel||')*/ '||
' distinct chartorowid(m_row$$) row_id ,0 status from '||g_src_object_ilog||
' MINUS select row_id row_id ,0 status from '||g_ilog;
l_stmt:=l_stmt||' as select distinct chartorowid(m_row$$) row_id,'||g_src_pk||',0 status from '||
g_src_object_ilog||' MINUS select row_id row_id,'||g_src_pk||',0 status from '||g_ilog;
l_stmt:=l_stmt||' as select distinct chartorowid(m_row$$) row_id ,0 status from '||g_src_object_ilog||
' MINUS select row_id row_id ,0 status from '||g_ilog;
l_stmt:='insert into '||g_ilog||'(row_id,'||g_src_pk||',status,round) select row_id,'||g_src_pk||
',status,0 from '||l_ilog_temp;
l_stmt:='insert into '||g_ilog||'(row_id, status,round) select row_id,status,0 from '||l_ilog_temp;
write_to_log_file_n('Inserted '||g_ilog||' with '||sql%rowcount||' records'||get_time);
g_skip_dlog_update:=true;
l_stmt:=l_stmt||' as select ';
l_stmt:=l_stmt||' as select /*+ORDERED ';
l_stmt:=l_stmt||' as select ';
l_stmt:=l_stmt||' as select row_id,0 status from '||l_dlog||' MINUS select row_id,0 status from '||g_dlog;
l_stmt:='insert into '||g_dlog||'(row_id,row_id1,status,pk_key,round) select ';
l_stmt:='insert into '||g_dlog||'(row_id,status) select row_id,status from '||l_dlog_temp;
write_to_log_file_n('Inserted '||g_dlog||' with '||sql%rowcount||' records'||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 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 where status=0';
l_stmt:='update '||g_ilog||' set status=1 where status=0 and 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_src_pk||',decode(status,1,2,2,2,decode(sign(rownum-'||
g_collection_size||'),1,0,1)) status,round from (select row_id,'||g_src_pk||',status,round 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,round from (select row_id,status,round from '||
g_ilog_prev||' order by status) abc ';
l_stmt:=l_stmt||' as select row_id,'||g_src_pk||',decode(status,1,2,0,1,2) status,round from '||
g_ilog_prev;
l_stmt:=l_stmt||' as select row_id,decode(status,1,2,0,1,2) status,round from '||
g_ilog_prev;
this function sets the status of the dlog 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_gdlog_status return number is
l_stmt varchar2(10000);
if g_type_dlog_generation='UPDATE' then
if g_collection_size =0 then
l_stmt:='update '||g_dlog||' set status=1 where status=0';
l_stmt:='update '||g_dlog||' set status=1 where status=0 and rownum <='||g_collection_size;
write_to_log_file_n('Updated '||l_count||' rows in '||g_dlog||get_time);
l_stmt:=l_stmt||' as select row_id,decode(status,1,2,2,2,decode(sign(rownum-'||
g_collection_size||'),1,0,1)) status,row_id1,pk_key,round from (select row_id,status,row_id1,pk_key,'||
'round from '||g_dlog_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_dlog_prev||' order by status) abc ';
l_stmt:=l_stmt||' as select row_id,decode(status,1,2,0,1,2) status,row_id1,pk_key,round from '||
g_dlog_prev;
l_stmt:=l_stmt||' as select row_id,decode(status,1,2,0,1,2) status from '||
g_dlog_prev;
l_dlog_desc :='Delete Log';
l_stmt:='select fk_item.column_name from edw_foreign_keys_md_v fk, '||
'edw_pvt_key_columns_md_v isu, '||
'edw_pvt_columns_md_v fk_item '||
'where '||
'fk.entity_id=:s '||
'and isu.key_id=fk.foreign_key_id '||
'and fk_item.column_id=isu.column_id';
l_stmt:=l_stmt||' as select ';
l_stmt:=l_stmt||' as select row_id from '||g_ilog||' where status=1';
l_stmt:=l_stmt||' as select ';
function make_delete_data_into_temp return boolean is
l_stmt varchar2(30000);
write_to_log_file_n('In move_delete_data_into_temp');
l_stmt:=l_stmt||' as select ';
g_delete_data_temp_stmt:=l_stmt;
write_to_log_file_n('Error in make_delete_data_into_temp '||sqlerrm||' '||get_time);
function execute_delete_data_into_temp return number is
l_status number :=0;
write_to_log_file_n('In execute_delete_data_into_temp');
l_stmt:=l_stmt||' as select row_id from '||g_dlog||' where status=1';
if make_delete_data_into_temp=false then
return 0;
write_to_log_file_n('Goint to execute '||g_delete_data_temp_stmt);
execute immediate g_delete_data_temp_stmt;
write_to_log_file_n('Error in execute_delete_data_into_temp '||sqlerrm||' '||get_time);
function make_delete_into_fact return boolean is
l_last_update_date_flag boolean;
write_to_log_file_n('In make_delete_into_fact');
g_number_input_params,'LAST_UPDATE_DATE')= false then
l_last_update_date_flag:=true;
l_last_update_date_flag:=false;
if g_update_type='DELETE-INSERT' then
g_delete_stmt:='insert into '||g_fact_name||' ( ';
g_delete_stmt:=g_delete_stmt||g_output_params(i)||',';
g_delete_stmt:=g_delete_stmt||'CREATION_DATE,';
if l_last_update_date_flag then
g_delete_stmt:=g_delete_stmt||'LAST_UPDATE_DATE,';
g_delete_stmt:=substr(g_delete_stmt,1,length(g_delete_stmt)-1);
g_delete_stmt:=g_delete_stmt||') select ';
g_delete_stmt:=g_delete_stmt||g_delete_rowid_table||'.'||g_output_params(i)||',';
g_delete_stmt:=g_delete_stmt||'SYSDATE,';
if l_last_update_date_flag then
g_delete_stmt:=g_delete_stmt||'SYSDATE,';
g_delete_stmt:=substr(g_delete_stmt,1,length(g_delete_stmt)-1);
g_delete_stmt:=g_delete_stmt||' from '||g_delete_rowid_table;
g_delete_stmt_row:='update '||g_fact_name||' set ( ';
if g_update_type='ROW-BY-ROW' then
g_delete_stmt:='update '||g_fact_name||' set ( ';
elsif g_update_type='MASS' then
if g_parallel is null then
g_delete_stmt:='update /*+ ORDERED USE_NL('||g_fact_name||')*/ '||g_fact_name||' set ( ';
g_delete_stmt:='update /*+ ORDERED USE_NL('||g_fact_name||')*/ /*+ PARALLEL ('||g_fact_name||','||
g_parallel||')*/ '||g_fact_name||' set ( ';
g_delete_stmt:=g_delete_stmt||g_output_params(i)||',';
g_delete_stmt_row:=g_delete_stmt_row||g_output_params(i)||',';
g_number_input_params,'LAST_UPDATE_DATE')= false then
l_last_update_date_flag:=true;
g_delete_stmt:=g_delete_stmt||'LAST_UPDATE_DATE,';
g_delete_stmt_row:=g_delete_stmt_row||'LAST_UPDATE_DATE,';
l_last_update_date_flag:=false;
g_delete_stmt:=substr(g_delete_stmt,1,length(g_delete_stmt)-1);
g_delete_stmt_row:=substr(g_delete_stmt_row,1,length(g_delete_stmt_row)-1);
g_delete_stmt:=g_delete_stmt||') = (select ';
g_delete_stmt_row:=g_delete_stmt_row||') = (select ';
g_delete_stmt:=g_delete_stmt||' nvl('||g_fact_name||'.'||g_output_params(i)||',0)-'||
g_delete_rowid_table||'.'||g_output_params(i)||',';
g_delete_stmt_row:=g_delete_stmt_row||' nvl('||g_fact_name||'.'||g_output_params(i)||',0)-'||
g_delete_rowid_table||'.'||g_output_params(i)||',';
if l_last_update_date_flag then
g_delete_stmt:=g_delete_stmt||'SYSDATE,';
g_delete_stmt_row:=g_delete_stmt_row||'SYSDATE,';
g_delete_stmt:=substr(g_delete_stmt,1,length(g_delete_stmt)-1);
g_delete_stmt_row:=substr(g_delete_stmt_row,1,length(g_delete_stmt_row)-1);
g_delete_stmt:=g_delete_stmt||' from '||g_delete_rowid_table||' where ';
g_delete_stmt_row:=g_delete_stmt_row||' from '||g_delete_rowid_table||' where ';
g_delete_stmt_row:=g_delete_stmt_row||g_delete_rowid_table||'.row_id1=:a) where '||g_fact_name||'.rowid=:b';
if g_update_type='ROW-BY-ROW' then
g_delete_stmt:=g_delete_stmt||g_delete_rowid_table||'.row_id1=:a) where '||g_fact_name||'.rowid=:b';
elsif g_update_type='MASS' then
g_delete_stmt:=g_delete_stmt||g_delete_rowid_table||'.row_id1='||g_fact_name||'.rowid ) where '||
g_fact_name||'.rowid in (select row_id1 from '||g_delete_rowid_table||')';
write_to_log_file_n('Error in make_delete_into_fact '||sqlerrm||' '||get_time);
function make_update_into_fact return boolean is
l_last_update_date_flag boolean;
write_to_log_file_n('In make_update_into_fact');
g_number_input_params,'LAST_UPDATE_DATE')= false then
l_last_update_date_flag:=true;
l_last_update_date_flag:=false;
if g_update_type='DELETE-INSERT' then
g_update_stmt:='insert into '||g_fact_name||' ( ';
g_update_stmt:=g_update_stmt||g_output_params(i)||',';
g_update_stmt:=g_update_stmt||'CREATION_DATE,';
if l_last_update_date_flag then
g_update_stmt:=g_update_stmt||'LAST_UPDATE_DATE,';
g_update_stmt:=substr(g_update_stmt,1,length(g_update_stmt)-1);
g_update_stmt:=g_update_stmt||') select ';
g_update_stmt:=g_update_stmt||g_update_rowid_table||'.'||g_output_params(i)||',';
g_update_stmt:=g_update_stmt||'SYSDATE,';
if l_last_update_date_flag then
g_update_stmt:=g_update_stmt||'SYSDATE,';
g_update_stmt:=substr(g_update_stmt,1,length(g_update_stmt)-1);
g_update_stmt:=g_update_stmt||' from '||g_update_rowid_table;
g_update_stmt_row:='update '||g_fact_name||' set ( ';
if g_update_type='ROW-BY-ROW' then
g_update_stmt:='update '||g_fact_name||' set ( ';
elsif g_update_type='MASS' then
if g_parallel is null then
g_update_stmt:='update /*+ ORDERED USE_NL('||g_fact_name||')*/ '||g_fact_name||' set ( ';
g_update_stmt:='update /*+ ORDERED USE_NL('||g_fact_name||')*/ /*+ PARALLEL ('||g_fact_name||','||
g_parallel||')*/ '||g_fact_name||' set ( ';
g_update_stmt:=g_update_stmt||g_output_params(i)||',';
g_update_stmt_row:=g_update_stmt_row||g_output_params(i)||',';
if l_last_update_date_flag then
g_update_stmt:=g_update_stmt||'LAST_UPDATE_DATE,';
g_update_stmt_row:=g_update_stmt_row||'LAST_UPDATE_DATE,';
g_update_stmt:=substr(g_update_stmt,1,length(g_update_stmt)-1);
g_update_stmt_row:=substr(g_update_stmt_row,1,length(g_update_stmt_row)-1);
g_update_stmt:=g_update_stmt||') = (select ';
g_update_stmt_row:=g_update_stmt_row||') = (select ';
g_update_stmt:=g_update_stmt||' nvl('||g_fact_name||'.'||g_output_params(i)||',0)+'||
g_update_rowid_table||'.'||g_output_params(i)||',';
g_update_stmt_row:=g_update_stmt_row||' nvl('||g_fact_name||'.'||g_output_params(i)||',0)+'||
g_update_rowid_table||'.'||g_output_params(i)||',';
if l_last_update_date_flag then
g_update_stmt:=g_update_stmt||'SYSDATE,';
g_update_stmt_row:=g_update_stmt_row||'SYSDATE,';
g_update_stmt:=substr(g_update_stmt,1,length(g_update_stmt)-1);
g_update_stmt_row:=substr(g_update_stmt_row,1,length(g_update_stmt_row)-1);
g_update_stmt:=g_update_stmt||' from '||g_update_rowid_table||' where ';
g_update_stmt_row:=g_update_stmt_row||' from '||g_update_rowid_table||' where ';
g_update_stmt_row:=g_update_stmt_row||g_update_rowid_table||'.row_id1=:a) where '||g_fact_name||'.rowid=:b';
if g_update_type='ROW-BY-ROW' then
g_update_stmt:=g_update_stmt||g_update_rowid_table||'.row_id1=:a) where '||g_fact_name||'.rowid=:b';
elsif g_update_type='MASS' then
g_update_stmt:=g_update_stmt||g_update_rowid_table||'.row_id1='||g_fact_name||'.rowid ) where '||
g_fact_name||'.rowid in (select row_id1 from '||g_update_rowid_table||')';
write_to_log_file_n('g_update_stmt is '||g_update_stmt);
write_to_log_file_n('Error in make_update_into_fact '||sqlerrm||' '||get_time);
function make_insert_into_fact return boolean is
l_creation_date_flag boolean;
l_last_update_date_flag boolean;
write_to_log_file_n('In make_insert_into_fact');
g_insert_stmt:='insert into '||g_fact_name||'(';
g_insert_stmt:='insert /*+ PARALLEL ('||g_fact_name||','||g_parallel||')*/ into '||g_fact_name||'(';
g_insert_stmt:=g_insert_stmt||' '||g_output_params(i)||',';
g_insert_stmt:=g_insert_stmt||' '||g_df_extra_fks(i)||',';
g_insert_stmt:=g_insert_stmt||'CREATION_DATE,';
g_number_input_params,'LAST_UPDATE_DATE')= false then
l_last_update_date_flag:=true;
g_insert_stmt:=g_insert_stmt||'LAST_UPDATE_DATE,';
l_last_update_date_flag:=false;
g_insert_stmt:=substr(g_insert_stmt,1,length(g_insert_stmt)-1);
g_insert_stmt:=g_insert_stmt||' ) select /*+ORDERED */ ';
g_insert_stmt:=g_insert_stmt||' '||g_output_params(i)||',';
g_insert_stmt:=g_insert_stmt||' '||g_df_extra_fks(i)||',';
g_insert_stmt:=g_insert_stmt||'SYSDATE,';
if l_last_update_date_flag then
g_insert_stmt:=g_insert_stmt||'SYSDATE,';
g_insert_stmt:=substr(g_insert_stmt,1,length(g_insert_stmt)-1);
g_insert_stmt:=g_insert_stmt||' from '||g_insert_rowid_table||','||g_temp_fact_name||
' where '||g_temp_fact_name||'.rowid='||g_insert_rowid_table||'.row_id';
write_to_log_file('The statement to insert into the IV');
write_to_log_file_n(g_insert_stmt);
write_to_log_file_n('Error in make_insert_into_fact '||sqlerrm||' '||get_time);
function delete_into_fact return boolean is
l_stmt varchar2(5000);
l_update_type varchar2(400);
write_to_log_file_n('In delete_into_fact');
l_update_type:=g_update_type;
<>
if l_update_type='ROW-BY-ROW' then
l_stmt:='select row_id1 from '||g_delete_rowid_table;
write_to_log_file('Going to execute '||g_delete_stmt_row||get_time);
execute immediate g_delete_stmt_row using l_rowid(i),l_rowid(i);
execute immediate g_delete_stmt_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_delete_stmt||get_time);
execute immediate g_delete_stmt;
write_to_log_file_n('Memory issue with Mass Update. Retrying using ROW_BY_ROW');
l_update_type:='ROW-BY-ROW';
goto start_delete;
goto start_delete;
write_to_log_file('Problem stmt '||g_delete_stmt);
elsif l_update_type='DELETE-INSERT' then
l_stmt:='delete '||g_fact_name||' where exists (select 1 from '||g_delete_rowid_table||' where '||
g_delete_rowid_table||'.row_id1='||g_fact_name||'.rowid)';
write_to_log_file('Deleted '||sql%rowcount||' rows'||get_time);
write_to_log_file_n('Going to execute '||g_delete_stmt||get_time);
execute immediate g_delete_stmt;--this is actually an insert
write_to_log_file('Problem stmt '||g_delete_stmt);
if make_delete_prot_log=false then --this is the commit
write_to_log_file_n('make_delete_prot_log returned with error');
g_total_delete:=nvl(g_total_delete,0)+l_total_count;
write_to_log_file_n('Number of rows updated for delete in the fact '||l_total_count);
write_to_log_file_n('Error in delete_into_fact '||sqlerrm||' '||get_time);
function update_into_fact return boolean is
l_stmt varchar2(5000);
l_update_type varchar2(400);
write_to_log_file_n('In update_into_fact');
l_update_type:=g_update_type;
<>
if l_update_type='ROW-BY-ROW' then
l_stmt:='select row_id1 from '||g_update_rowid_table;
write_to_log_file_n('Goint to execute '||g_update_stmt_row||get_time);
execute immediate g_update_stmt_row using l_rowid(i),l_rowid(i);
execute immediate g_update_stmt_row using l_rowid(i),l_rowid(i);
elsif g_update_type='MASS' then
begin
if g_debug then
write_to_log_file('Going to execute '||g_update_stmt);
execute immediate g_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;
goto start_update;
write_to_log_file('Problem stmt '||g_update_stmt);
elsif g_update_type='DELETE-INSERT' then
l_stmt:='delete '||g_fact_name||' where exists (select 1 from '||g_update_rowid_table||' where '||
g_update_rowid_table||'.row_id1='||g_fact_name||'.rowid)';
write_to_log_file('Deleted '||sql%rowcount||' rows');
write_to_log_file('Going to execute '||g_update_stmt);
execute immediate g_update_stmt;--this is actually an insert
write_to_log_file('Problem stmt '||g_update_stmt);
if make_update_prot_log=false then --this is the commit
write_to_log_file_n('make_update_prot_log returned with error');
g_total_update:=nvl(g_total_update,0)+l_total_count;
write_to_log_file_n('Number of rows updated in the fact '||l_total_count);
write_to_log_file_n('Error in update_into_fact '||sqlerrm||' '||get_time);
function insert_into_fact return boolean is
l_count number;
write_to_log_file_n('In insert_into_fact');
write_to_log_file('Going to execute '||g_insert_stmt);
execute immediate g_insert_stmt;
if make_insert_prot_log=false then --this is the commit!!
write_to_log_file_n('make_insert_prot_log returned with error');
g_total_insert:=nvl(g_total_insert,0)+l_count;
write_to_log_file_n('Error in insert_into_fact '||sqlerrm||' '||get_time);
if EDW_OWB_COLLECTION_UTIL.drop_table(g_insert_rowid_table)=false then
null;
if EDW_OWB_COLLECTION_UTIL.drop_table(g_update_rowid_table)=false then
null;
if EDW_OWB_COLLECTION_UTIL.drop_table(g_delete_rowid_table)=false then
null;
function update_log_status_0(p_log varchar2) return boolean is
l_stmt varchar2(2000);
write_to_log_file_n('In update_ilog_status_2');
l_stmt:='update '||p_log||' set status=0 where status=1';
write_to_log_file_n('Updated '||sql%rowcount||' rows in '||p_log||' from status 1 to status 0'||get_time);
function update_ilog_status_2 return boolean is
l_stmt varchar2(2000);
write_to_log_file_n('In update_ilog_status_2');
l_stmt:='update '||g_ilog||' set status=2 where status=1';
write_to_log_file_n('Updated '||sql%rowcount||' rows in '||g_ilog||' from status 1 to status 2'||get_time);
function update_dlog_status_2 return boolean is
l_stmt varchar2(2000);
write_to_log_file_n('In update_dlog_status_2');
l_stmt:='update '||g_dlog||' set status=2 where status=1';
write_to_log_file_n('Updated '||sql%rowcount||' rows in '||g_dlog||' from status 1 to status 2'||get_time);
function delete_rowid_table_stmt return boolean is
l_divide number:=2;
write_to_log_file_n('In delete_rowid_table_stmt');
g_delete_rowid_stmt:='create table '||g_delete_rowid_table||' tablespace '||g_op_table_space;
g_delete_rowid_stmt:=g_delete_rowid_stmt||' storage(initial '||g_fact_next_extent/2||' next '||
(g_fact_next_extent/l_divide)||' pctincrease 0 MAXEXTENTS 2147483645) ';
g_delete_rowid_stmt:=g_delete_rowid_stmt||' parallel (degree '||g_parallel||') ';
g_delete_rowid_stmt:=g_delete_rowid_stmt||' ';
g_delete_rowid_stmt:=g_delete_rowid_stmt||' as select /*+ ORDERED */ ';
if g_update_type='DELETE-INSERT' then
for i in 1..g_number_input_params loop
if g_fk_flag(i)=false and g_groupby_col_flag(i)=false then
g_delete_rowid_stmt:=g_delete_rowid_stmt||'nvl('||g_fact_name||'.'||g_output_params(i)||',0)-nvl('||
g_temp_fact_name||'.'||g_output_params(i)||',0) '||g_output_params(i)||',';
g_delete_rowid_stmt:=g_delete_rowid_stmt||g_temp_fact_name||'.'||g_output_params(i)||' '||
g_output_params(i)||',';
g_delete_rowid_stmt:=g_delete_rowid_stmt||' nvl('||g_temp_fact_name||'.'||g_output_params(i)||',0) '||
g_output_params(i)||',';
if g_update_type='DELETE-INSERT' then
g_delete_rowid_stmt:=g_delete_rowid_stmt||g_fact_name||'.rowid row_id1,'||
g_fact_name||'.CREATION_DATE CREATION_DATE from '||g_temp_fact_name||','||g_fact_name||' where ';
g_delete_rowid_stmt:=g_delete_rowid_stmt||g_fact_name||'.rowid row_id1 from '||g_temp_fact_name||','||
g_fact_name||' where ';
g_delete_rowid_stmt:=g_delete_rowid_stmt||' '||g_fact_name||'.'||g_output_group_by_cols(i)||'='||
g_temp_fact_name||'.'||g_output_group_by_cols(i)||' and ';
g_delete_rowid_stmt:=g_delete_rowid_stmt||' nvl('||g_fact_name||'.'||g_output_group_by_cols(i)||',0)=nvl('||
g_temp_fact_name||'.'||g_output_group_by_cols(i)||',0) and ';
g_delete_rowid_stmt:=g_delete_rowid_stmt||' nvl('||g_fact_name||'.'||g_output_group_by_cols(i)||
',sysdate)=nvl('||g_temp_fact_name||'.'||g_output_group_by_cols(i)||',sysdate) and ';
g_delete_rowid_stmt:=g_delete_rowid_stmt||' '||g_fact_name||'.'||g_output_group_by_cols(i)||'='||
g_temp_fact_name||'.'||g_output_group_by_cols(i)||' and ';
g_delete_rowid_stmt:=g_delete_rowid_stmt||' '||g_fact_name||'.'||g_output_group_by_cols(i)||'='||
g_temp_fact_name||'.'||g_output_group_by_cols(i)||' and ';
g_delete_rowid_stmt:=substr(g_delete_rowid_stmt,1,length(g_delete_rowid_stmt)-4);
function update_rowid_table_stmt return boolean is
l_divide number:=2;
write_to_log_file_n('In update_rowid_table_stmt');
g_update_rowid_stmt:='create table '||g_update_rowid_table||' tablespace '||g_op_table_space;
g_update_rowid_stmt:=g_update_rowid_stmt||' storage(initial '||g_fact_next_extent/2||' next '||
(g_fact_next_extent/l_divide)||' pctincrease 0 MAXEXTENTS 2147483645) ';
g_update_rowid_stmt:=g_update_rowid_stmt||' parallel (degree '||g_parallel||') ';
g_update_rowid_stmt:=g_update_rowid_stmt||' ';
g_update_rowid_stmt:=g_update_rowid_stmt||' as select /*+ ORDERED */ ';
if g_update_type='DELETE-INSERT' then
for i in 1..g_number_input_params loop
if g_fk_flag(i)=false and g_groupby_col_flag(i)=false then
g_update_rowid_stmt:=g_update_rowid_stmt||' nvl('||g_fact_name||'.'||g_output_params(i)||',0)+nvl('||
g_temp_fact_name||'.'||g_output_params(i)||',0) '||g_output_params(i)||',';
else --we need the keys also in this update mode for inserts
g_update_rowid_stmt:=g_update_rowid_stmt||g_temp_fact_name||'.'||g_output_params(i)||' '||
g_output_params(i)||',';
g_update_rowid_stmt:=g_update_rowid_stmt||' nvl('||g_temp_fact_name||'.'||g_output_params(i)||',0) '||
g_output_params(i)||',';
if g_update_type='DELETE-INSERT' then
g_update_rowid_stmt:=g_update_rowid_stmt||g_fact_name||'.rowid row_id1,'||
g_fact_name||'.CREATION_DATE CREATION_DATE from '||g_temp_fact_name||','||g_fact_name||' where ';
g_update_rowid_stmt:=g_update_rowid_stmt||g_fact_name||'.rowid row_id1,'||g_temp_fact_name||'.rowid row_id '||
' from '||g_temp_fact_name||','||g_fact_name||' where ';
g_update_rowid_stmt:=g_update_rowid_stmt||' '||g_fact_name||'.'||g_output_group_by_cols(i)||'='||
g_temp_fact_name||'.'||g_output_group_by_cols(i)||' and ';
g_update_rowid_stmt:=g_update_rowid_stmt||' nvl('||g_fact_name||'.'||g_output_group_by_cols(i)||',0)=nvl('||
g_temp_fact_name||'.'||g_output_group_by_cols(i)||',0) and ';
g_update_rowid_stmt:=g_update_rowid_stmt||' nvl('||g_fact_name||'.'||g_output_group_by_cols(i)||
',sysdate)=nvl('||g_temp_fact_name||'.'||g_output_group_by_cols(i)||',sysdate) and ';
g_update_rowid_stmt:=g_update_rowid_stmt||' '||g_fact_name||'.'||g_output_group_by_cols(i)||'='||
g_temp_fact_name||'.'||g_output_group_by_cols(i)||' and ';
g_update_rowid_stmt:=g_update_rowid_stmt||' '||g_fact_name||'.'||g_output_group_by_cols(i)||'='||
g_temp_fact_name||'.'||g_output_group_by_cols(i)||' and ';
g_update_rowid_stmt:=substr(g_update_rowid_stmt,1,length(g_update_rowid_stmt)-4);
function insert_rowid_table_stmt return boolean is
Begin
if g_debug then
write_to_log_file_n('In insert_rowid_table_stmt');
g_insert_rowid_stmt:='create table '||g_insert_rowid_table||' tablespace '||g_op_table_space;
g_insert_rowid_stmt:=g_insert_rowid_stmt||' parallel (degree '||g_parallel||') ';
g_insert_rowid_stmt:=g_insert_rowid_stmt||' ';
g_insert_rowid_stmt:=g_insert_rowid_stmt||' as select rowid row_id from '||
g_temp_fact_name||' MINUS select row_id row_id from '||g_update_rowid_table||' ';
write_to_log_file_n('g_insert_rowid_stmt is '||g_insert_rowid_stmt);
if EDW_OWB_COLLECTION_UTIL.drop_table(g_delete_rowid_table) = false then
write_to_log_file_n('Table '||g_delete_rowid_table||' not found for dropping');
write_to_log_file_n('Going to execute '||g_delete_rowid_stmt||get_time);
execute immediate g_delete_rowid_stmt;
write_to_log_file_n('Moved '||sql%rowcount||' rows into the delete rowid table');
if create_insert_lock_table=false then
return false;
if EDW_OWB_COLLECTION_UTIL.drop_table(g_update_rowid_table) = false then
write_to_log_file_n('Table '||g_update_rowid_table||' not found for dropping');
l_stmt:='create table '||g_update_rowid_table||'(row_id rowid,row_id1 rowid)'||
' tablespace '||g_op_table_space;
write_to_log_file_n('Going to execute '||g_update_rowid_stmt||get_time);
execute immediate g_update_rowid_stmt;
write_to_log_file_n('Moved '||sql%rowcount||' rows into the update rowid table');
if EDW_OWB_COLLECTION_UTIL.drop_table(g_insert_rowid_table) = false then
write_to_log_file_n('Table '||g_insert_rowid_table||' not found for dropping');
write_to_log_file_n('Going to execute '||g_insert_rowid_stmt);
execute immediate g_insert_rowid_stmt;
write_to_log_file_n('Moved '||l_count||' rows into the insert rowid table');
if l_count=0 then --then there is no need to keep this table as a lock as there are going to be no inserts
if drop_insert_lock_table=false then
return false;
l_stmt:='create unique index '||g_delete_rowid_table||'u1 on '||g_delete_rowid_table||'(row_id1) '||
' tablespace '||g_op_table_space;
EDW_OWB_COLLECTION_UTIL.analyze_table_stats(substr(g_delete_rowid_table,instr(g_delete_rowid_table,'.')+1,
length(g_delete_rowid_table)),substr(g_delete_rowid_table,1,instr(g_delete_rowid_table,'.')-1));
l_stmt:='create unique index '||g_update_rowid_table||'u1 on '||g_update_rowid_table||'(row_id1) '||
' tablespace '||g_op_table_space;
EDW_OWB_COLLECTION_UTIL.analyze_table_stats(substr(g_insert_rowid_table,instr(g_insert_rowid_table,'.')+1,
length(g_insert_rowid_table)),substr(g_insert_rowid_table,1,instr(g_insert_rowid_table,'.')-1));
EDW_OWB_COLLECTION_UTIL.analyze_table_stats(substr(g_update_rowid_table,instr(g_update_rowid_table,'.')+1,
length(g_update_rowid_table)),substr(g_update_rowid_table,1,instr(g_update_rowid_table,'.')-1));
g_insert_lock_table:=g_bis_owner||'.INSERT_LOCK_'||g_fact_id;--should this be a passed down parameter?
g_insert_rowid_table:=g_bis_owner||'.'||l_fact_name||'IR';
g_update_rowid_table:=g_bis_owner||'.'||l_fact_name||'UR';
g_delete_rowid_table:=g_bis_owner||'.'||l_fact_name||'DR';
g_insert_prot_log :=g_bis_owner||'.'||l_fact_name||'PI';
g_update_prot_log :=g_bis_owner||'.'||l_fact_name||'PU';
g_delete_prot_log :=g_bis_owner||'.'||l_fact_name||'PD';
g_total_insert:=0;
g_total_update:=0;
g_total_delete:=0;
g_skip_ilog_update:=false;
g_skip_dlog_update:=false;
l_stmt:=l_stmt||' as select ';
l_stmt:=l_stmt||' as select ';
l_stmt:=l_stmt||' as select ';
l_stmt:=l_stmt||' as select ';
if EDW_OWB_COLLECTION_UTIL.drop_table(g_insert_prot_log)=false then
null;
if EDW_OWB_COLLECTION_UTIL.drop_table(g_update_prot_log)=false then
null;
if EDW_OWB_COLLECTION_UTIL.drop_table(g_delete_prot_log)=false then
null;
function make_insert_prot_log return boolean is
l_stmt varchar2(2000);
l_stmt:='create table '||g_insert_prot_log||' tablespace '||g_op_table_space||
' storage(initial 4M next 4M pctincrease 0) ';
l_stmt:=l_stmt||' as select row_id from '||g_ilog||' where status=1';
EDW_OWB_COLLECTION_UTIL.analyze_table_stats(substr(g_insert_prot_log,instr(g_insert_prot_log,'.')+1,
length(g_insert_prot_log)),substr(g_insert_prot_log,1,instr(g_insert_prot_log,'.')-1));
write_to_log_file_n('Error in make_insert_prot_log '||g_status_message);
function make_update_prot_log return boolean is
l_stmt varchar2(2000);
l_stmt:='create table '||g_update_prot_log||' tablespace '||g_op_table_space||
' storage(initial 4M next 4M pctincrease 0) ';
l_stmt:=l_stmt||' as select row_id from '||g_ilog||' where status=1';
EDW_OWB_COLLECTION_UTIL.analyze_table_stats(substr(g_update_prot_log,instr(g_update_prot_log,'.')+1,
length(g_update_prot_log)),substr(g_update_prot_log,1,instr(g_update_prot_log,'.')-1));
function make_delete_prot_log return boolean is
l_stmt varchar2(2000);
l_stmt:='create table '||g_delete_prot_log||' tablespace '||g_op_table_space||
' storage(initial 4M next 4M pctincrease 0) ';
l_stmt:=l_stmt||' as select row_id from '||g_dlog||' where status=1';
EDW_OWB_COLLECTION_UTIL.analyze_table_stats(substr(g_delete_prot_log,instr(g_delete_prot_log,'.')+1,
length(g_delete_prot_log)),substr(g_delete_prot_log,1,instr(g_delete_prot_log,'.')-1));
procedure insert_into_temp_log(p_flag varchar2) is
Begin
g_number_ins_req_coll:=1;
else --delete data
g_ins_rows_ready(1):=g_ins_rows_processed;
if EDW_OWB_COLLECTION_UTIL.insert_temp_log_table(
g_fact_name,
'FACT',
g_conc_id,
g_ins_instance_name,
g_ins_request_id_table,
g_ins_rows_ready,
g_ins_rows_processed_tab,
g_ins_rows_collected,
g_ins_rows_dangling,
g_ins_rows_duplicate,
g_ins_rows_error,
null,
g_total_insert,
g_total_update,
g_total_delete,
g_number_ins_req_coll) = false then
g_status_message:=EDW_OWB_COLLECTION_UTIL.g_status_message;
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_fact_id,p_load_progress,p_start_date,
p_end_date,p_category,p_operation,p_seq_id,p_flag,g_fact_id);
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_fact_id,p_load_progress,p_start_date,
p_end_date,p_category,p_operation,p_seq_id,p_flag,g_fact_id);
l_stmt:='select /*+parallel('||g_src_object||','||g_parallel||')*/ count(*) from '||g_src_object;
l_stmt:='select count(*) from '||g_src_object;
g_skip_ilog_update:=true;
' as select rowid row_id,-10 '||g_src_pk||', 1 status from dual ';
' as select rowid row_id, 1 status from dual ';
g_skip_dlog_update:=true;
' as select rowid row_id, 1 status from dual ';
function load_new_update_data return boolean is
l_stmt varchar2(10000);
write_to_log_file_n('In load_new_update_data'||get_time);
l_stmt:=l_stmt||' as select B.'||l_col||',B.'||l_round||' from '||g_ilog||' A,'||g_dlog||' B where '||
' A.row_id=B.row_id1 and A.status=2';
l_stmt:=l_stmt||' as select /*+ordered*/ ';
l_stmt:=l_stmt||' as select A.rowid row_id from '||l_table_dlog||' A,'||g_ilog||' B where ';
l_stmt:=l_stmt||' as select rowid row_id from '||l_table_dlog||' MINUS select row_id from '||
l_table_1;
l_stmt:='insert into '||g_ilog||'(row_id,status,'||l_round||','||g_src_pk||') select row_id1,0,'||
l_round||','||l_dlog_col||' from '||l_table_2||','||l_table_dlog||' where '||l_table_2||'.row_id='||
l_table_dlog||'.rowid';
l_stmt:='insert into '||g_ilog||'(row_id,status,'||l_round||') select row_id1,0,'||l_round||
' from '||l_table_2||','||l_table_dlog||' where '||l_table_2||'.row_id='||l_table_dlog||'.rowid';
write_to_log_file_n('Inserted '||l_count||' rows '||get_time);
l_stmt:='insert into '||g_dlog||'(row_id,row_id1,status,'||l_round||','||l_col||') select B.row_id,B.row_id1,'||
'0,B.'||l_round||',B.'||l_dlog_col||' from '||l_table_2||' A,'||l_table_dlog||' B where '||
'A.row_id=B.rowid';
write_to_log_file_n('Inserted '||l_count||' rows '||get_time);
if EDW_OWB_COLLECTION_UTIL.merge_all_prot_tables(g_insert_prot_log,'PI',g_op_table_space,g_bis_owner,
g_parallel)=false then
return false;
if EDW_OWB_COLLECTION_UTIL.merge_all_prot_tables(g_update_prot_log,'PU',g_op_table_space,g_bis_owner,
g_parallel)=false then
return false;
if EDW_OWB_COLLECTION_UTIL.merge_all_prot_tables(g_delete_prot_log,'PD',g_op_table_space,g_bis_owner,
g_parallel)=false then
return false;
if EDW_OWB_COLLECTION_UTIL.check_table(g_insert_prot_log) then
g_stmt:='update '||g_ilog||' set status=2 where row_id in (select row_id from '||g_insert_prot_log||')';
elsif EDW_OWB_COLLECTION_UTIL.check_table(g_update_prot_log) then
g_stmt:='update '||g_ilog||' set status=2 where row_id in (select row_id from '||g_update_prot_log||')';
elsif EDW_OWB_COLLECTION_UTIL.check_table(g_delete_prot_log) then
g_stmt:='update '||g_dlog||' set status=2 where row_id in (select row_id from '||g_delete_prot_log||')';
write_to_log_file_n('Updated '||sql%rowcount||' rows '||get_time);
l_skip_ilog_update varchar2(2);
l_skip_dlog_update varchar2(2);
g_stmt:='select '||
'fact_id,'||
'mapping_id,'||
'src_object,'||
'src_object_id,'||
'conc_id,'||
'conc_program_name,'||
'debug,'||
'collection_size,'||
'parallel,'||
'bis_owner,'||
'table_owner ,'||
'full_refresh,'||
'forall_size,'||
'update_type,'||
'fact_dlog,'||
'load_fk,'||
'fresh_restart,'||
'op_table_space,'||
'bu_src_fact,'||
'load_mode,'||
'rollback,'||
'src_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,'||
'dlog_table,'||
'skip_ilog_update,'||
'skip_dlog_update,'||
'skip_ilog,'||
'src_object_ilog,'||
'src_object_dlog,'||
'src_snplog_has_pk,'||
'err_rec_flag,'||
'err_rec_flag_d,'||
'dbms_job_id '||
' from '||p_table;
,g_update_type
,g_fact_dlog
,g_load_fk
,l_fresh_restart
,g_op_table_space
,g_bu_src_fact
,g_load_mode
,g_rollback
,g_src_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_name
,g_dlog_name
,l_skip_ilog_update
,l_skip_dlog_update
,l_skip_ilog
,g_src_object_ilog
,g_src_object_dlog
,l_src_snplog_has_pk
,l_err_rec_flag
,l_err_rec_flag_d
,g_dbms_job_id;
write_to_log_file('g_update_type='||g_update_type);
write_to_log_file('l_skip_ilog_update='||l_skip_ilog_update);
write_to_log_file('l_skip_dlog_update='||l_skip_dlog_update);
g_skip_ilog_update:=false;
g_skip_dlog_update:=false;
if l_skip_ilog_update='Y' then
g_skip_ilog_update:=true;
if l_skip_dlog_update='Y' then
g_skip_dlog_update:=true;
g_stmt:='select '||
'fact_fks,'||
'higher_level,'||
'parent_dim,'||
'parent_level,'||
'level_prefix,'||
'level_pk,'||
'level_pk_key,'||
'dim_pk_key '||
' from '||l_fk_table;
g_stmt:='select skip_cols from '||l_skip_table;
g_stmt:='select bu_tables,bu_dimensions from '||l_bu_table;
g_skip_ilog_update:=false;
g_skip_ilog_update:=true;
g_skip_dlog_update:=false;
g_skip_dlog_update:=true;
both trying to insert into the fact, there will be duplicate rows.
so keep insert locked. so inserts will be single threaded.
*/
function create_insert_lock_table return boolean is
l_stmt varchar2(2000);
write_to_log_file_n('In create_insert_lock_table '||get_time);
g_stmt:='create table '||g_insert_lock_table||' tablespace '||g_op_table_space||
' as select nvl('||l_my_conc_id||',-1) conc_id, nvl('||l_my_job_id||',-1) dbms_job_id from dual';
l_stmt:='select conc_id,dbms_job_id from '||g_insert_lock_table;
write_to_log_file_n('Created '||g_insert_lock_table||get_time);
if EDW_OWB_COLLECTION_UTIL.drop_table(g_insert_lock_table)=false then
null;
if EDW_OWB_COLLECTION_UTIL.drop_table(g_insert_lock_table)=false then
null;
write_to_log_file_n('Error in create_insert_lock_table '||g_status_message);
function drop_insert_lock_table return boolean is
Begin
if g_debug then
write_to_log_file_n('In drop_insert_lock_table');
if EDW_OWB_COLLECTION_UTIL.drop_table(g_insert_lock_table)=false then
null;
write_to_log_file_n('Error in drop_insert_lock_table '||g_status_message);
insert_into_load_progress(g_load_fk,g_fact_name,'Pre Fact Load Hook',sysdate,null,'DF',
'PRE-FACT-HOOK','PREDFHOOK'||g_fact_id||'-'||g_src_object_id,'I');
insert_into_load_progress(g_load_fk,null,null,null,sysdate,null,null,'PREDFHOOK'||g_fact_id||'-'||g_src_object_id,
'U');
insert_into_load_progress(g_load_fk,g_fact_name,'Post Fact Load Hook',sysdate,null,'DF',
'POST-FACT-HOOK','PDFHOOK'||g_fact_id||'-'||g_src_object_id,'I');
insert_into_load_progress(g_load_fk,null,null,null,sysdate,null,null,'PDFHOOK'||g_fact_id||'-'||g_src_object_id,
'U');