CREATE OR REPLACE
FUNCTION ecisdrdm.pr_merge_staging_tables(
OUT
v_ret text)
RETURNS text
LANGUAGE 'plpgsql'
COST 100
VOLATILE
AS $BODY$
DECLARE
v_errorcode
text;
v_errormsg
varchar(512);
v_module
varchar(32) = 'pr_merge_staging_tables';
v_host varchar(32)
= inet_server_addr();
begin
PERFORM
ecisdrdm.pr_write_error_log( CURRENT_USER, v_host,
v_module, '0', 'Starting MERGE Process' );
begin
v_ret
= '0';
if
v_ret = '0' then
---
---
Perform the merge on APPLICATION_CDIM
---
PERFORM
ecisdrdm.pr_write_error_log( CURRENT_USER, v_host,
v_module, '0', 'Started merging STG_APPLICATION_CDIM' );
PERFORM
ecisdrdm.pr_mig_stg_application_cdim();
--
TODO: INVESTIGATE HOW TO RECEIVE THE OUT PARAMETER
RETRUNED FROM FUNCTION
v_ret
= '0';
PERFORM
ecisdrdm.pr_write_error_log( CURRENT_USER, v_host,
v_module, '0', 'Finished merging STG_APPLICATION_CDIM'
);
end
if;
/*
exception
when
others then
GET
STACKED DIAGNOSTICS v_ret = PG_EXCEPTION_CONTEXT;
RAISE
INFO 'Error Name:%',SQLERRM;
RAISE
INFO 'Error State:%', SQLSTATE;
RAISE
INFO 'Error Context:%', v_errorcode;
*/
end;
----
---
2. STG_BNFT_CURR_FACT
----
if
v_ret = '0' then
---
---
Perform the merge on BNFT_CURR_FACT
---
PERFORM
ecisdrdm.pr_write_error_log( CURRENT_USER, v_host,
v_module, '0', 'Started merging STG_BNFT_CURR_FACT' );
PERFORM
ecisdrdm.pr_mig_stg_bnft_curr_fact();
--
TODO: INVESTIGATE HOW TO RECEIVE THE OUT PARAMETER
RETRUNED FROM FUNCTION
v_ret
= '0';
PERFORM
ecisdrdm.pr_write_error_log( CURRENT_USER, v_host,
v_module, '0', 'Finished merging STG_BNFT_CURR_FACT' );
end
if;
----
--
3. STG_BNFT_FACT
----
if
v_ret = '0' then
---
---
Perform the merge on BNFT_FACT
---
PERFORM
ecisdrdm.pr_write_error_log( CURRENT_USER, v_host,
v_module, '0', 'Started merging STG_BNFT_FACT' );
PERFORM
ecisdrdm.pr_mig_stg_bnft_fact();
--
TODO: INVESTIGATE HOW TO RECEIVE THE OUT PARAMETER
RETRUNED FROM FUNCTION
v_ret
= '0';
PERFORM
ecisdrdm.pr_write_error_log( CURRENT_USER, v_host,
v_module, '0', 'Finished merging STG_BNFT_FACT' );
end
if;
----
--
4. STG_BNFT_HIST_ACTN_LDIM
----
if
v_ret = '0' then
---
---
Perform the merge on BNFT_HIST_ACTN_LDIM
---
PERFORM
ecisdrdm.pr_write_error_log( CURRENT_USER, v_host,
v_module, '0', 'Started merging STG_BNFT_HIST_ACTN_LDIM
' );
PERFORM
ecisdrdm.pr_mig_stg_bnft_hist_actn_ldim ();
--
TODO: INVESTIGATE HOW TO RECEIVE THE OUT PARAMETER
RETRUNED FROM FUNCTION
v_ret
= '0';
PERFORM
ecisdrdm.pr_write_error_log( CURRENT_USER, v_host,
v_module, '0', 'Finished merging STG_BNFT_HIST_ACTN_LDIM
' );
end
if;
----
--
5. STG_CNTRY_ST_CDIM
----
if
v_ret = '0' then
---
---
Perform the merge on CNTRY_ST_CDIM
---
PERFORM
ecisdrdm.pr_write_error_log( CURRENT_USER, v_host,
v_module, '0','Started merging STG_CNTRY_ST_CDIM ' );
PERFORM
ecisdrdm.pr_mig_stg_cntry_st_cdim();
--
TODO: INVESTIGATE HOW TO RECEIVE THE OUT PARAMETER
RETRUNED FROM FUNCTION
v_ret
= '0';
PERFORM
ecisdrdm.pr_write_error_log( CURRENT_USER, v_host,
v_module, '0', 'Finished merging STG_CNTRY_ST_CDIM ');
end
if;
----
--
6. STG_FRM_CDIM
----
if
v_ret = '0' then
---
---
Perform the merge on FRM_CDIM
---
PERFORM
ecisdrdm.pr_write_error_log( CURRENT_USER, v_host,
v_module, '0', 'Started merging STG_FRM_CDIM ' );
PERFORM
ecisdrdm.pr_mig_stg_frm_cdim();
--
TODO: INVESTIGATE HOW TO RECEIVE THE OUT PARAMETER
RETRUNED FROM FUNCTION
v_ret
= '0';
PERFORM
ecisdrdm.pr_write_error_log( CURRENT_USER, v_host,
v_module, '0', 'Finished merging STG_FRM_CDIM ' );
end
if;