sql files

This commit is contained in:
dheepa
2021-07-02 08:40:37 +00:00
commit a0d3257be0
154 changed files with 49773 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,219 @@
drop function if exists fw_core.fn_run_master_wrapper;
CREATE OR REPLACE FUNCTION fw_core.fn_run_master_wrapper(p_client_id int,p_function_id int,p_job_id int,p_step_id int)
RETURNS void AS $$
declare
f record;
stg2_status text;
success_sum int;
err_file_syspk int;
TRX_status text;
w_job_id int := p_job_id;
w_step_id int := p_step_id;
w_function_id int := p_function_id;
w_client_id int := p_client_id;
begin
-- update fw_core.fw_jobctl_runschedule_jobstep set begin_status='started',start_time=now() where job_id = w_job_id and step_id = w_step_id and latest_runschedule_flag = '1';
for f in select distinct file_syspk,file_mnemonic,file_sheet_mnemonic,sheet_id
from fw_core.fw_jobctl_file_sheet_runschedule where file_sheet_mnemonic !=''
and latest_runschedule_flag = '1' and end_status != 'error' and end_status_note = 'generic_validation_completed'
order by file_syspk,sheet_id
loop
if err_file_syspk = f.file_syspk then
--incase of file stg2/trx fail then dont run script for those files and rollback previous change if any.
--rollback for that file syspk needs to be added
--perform staging2.run_trx_rollback(f.file_syspk)
continue;
else
--run staging 2 scripts depending on sheet mnemonic
if f.file_sheet_mnemonic = 'FTDRY_TRS' then
perform fw_core.fn_get_function_exception('staging2.fn_FTDRY_TRS_Block('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'FTDRY_SUM' then
perform fw_core.fn_get_function_exception('staging2.fn_FTDRY_SUM_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'FTWET_TRS' then
perform fw_core.fn_get_function_exception('staging2.fn_ftwet_trs_block('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'FTWET_SUM' then
perform fw_core.fn_get_function_exception('staging2.fn_FTWET_SUM_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'FTHLG_TRS' then
perform fw_core.fn_get_function_exception('staging2.fn_FTHLG_TRS_Block('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'FTHLG_SUM' then
perform fw_core.fn_get_function_exception('staging2.fn_FTHLG_SUM_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'DBSTD_TEST' then
perform fw_core.fn_get_function_exception('staging2.fn_dbstd_test_block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'DBOECD_TEST' then
perform fw_core.fn_get_function_exception('staging2.fn_dboecd_test_block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic in ('PTOBEN_PRFN','PTOBEN_PRFE','PTOBEN_PRFB','PTOSTD_PRF') then
perform fw_core.fn_get_function_exception('staging2.fn_PTO_PRF_block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic in ('PTOBEN_MPM','PTOSTD_MPM') then
perform fw_core.fn_get_function_exception('staging2.fn_PTO_MPM_block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic in ('PTOBEN_GVG','PTOSTD_GVG') then
perform fw_core.fn_get_function_exception('staging2.fn_PTO_GVG_block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_BRK' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_BRK_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_FLD' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_FLD_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_HDL' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_HDL_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_NMT' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_NMT_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_HLG' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_HLG_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_PTO' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_PTO_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_VMT' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_VMT_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_ARC' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_ARC_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_DBP' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_DBP_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_LCG' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_LCG_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTCGM_CGM' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTCGM_CGM_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTEMT_STD' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTEMT_STD_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTEMT_EMT' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTEMT_EMT_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTHAM_HAM' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTHAM_HAM_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTHLS_HLS' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTHLS_HLS_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTNST_NST' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTNST_NST_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTSLL_SLL' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTSLL_SLL_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTBT30_BT30' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTBT30_BT30_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTBT50_BT50' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTBT50_BT50_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTBTD_BTD' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTBTD_BTD_Block ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||f.file_sheet_mnemonic||''','||f.file_syspk||')');
else perform fw_core.fn_insert_db_error ( w_function_id, w_function_id, 1001, 'Compegence', f.file_syspk ,f.file_mnemonic,f.file_sheet_mnemonic ,null,'stg2 wrapper', 'unknown block', null, 'no script found', 'Script not present for the particlar sheet mnemonic', null, null,'error');
end if;
-- check if staging 2 script ran correctly and update fw_jobctl_file_sheet_runschedule table.
select e.status from fw_core.db_run_status e where file_syspk = f.file_syspk and file_sheet_mnemonic =f.file_sheet_mnemonic and staging_type = 'stg2' order by error_timestamp desc into stg2_status;
if stg2_status = 'success' then
update fw_core.fw_jobctl_file_sheet_runschedule set end_status_note = 'stg2_completed', end_status='success',staging_type = 'stg2',end_time = (select e.error_timestamp from fw_core.db_run_status e where e.file_syspk=f.file_syspk and e.file_sheet_mnemonic =f.file_sheet_mnemonic and e.staging_type = 'stg2' order by e.error_timestamp desc limit 1)
where file_syspk=f.file_syspk and file_sheet_mnemonic =f.file_sheet_mnemonic;
else
update fw_core.fw_jobctl_file_sheet_runschedule set end_status_note = 'stg2_failed', end_status='error',staging_type = 'stg2',end_time = (select e.error_timestamp from fw_core.db_run_status e where e.file_syspk=f.file_syspk and e.file_sheet_mnemonic =f.file_sheet_mnemonic and e.staging_type = 'stg2' order by e.error_timestamp desc limit 1)
where file_syspk=f.file_syspk and file_sheet_mnemonic =f.file_sheet_mnemonic;
--if error occured store in err_file_syspk variable and go to next file in loop
err_file_syspk := f.file_syspk;
continue;
end if;
--run transactional scripts depending on sheet mnemonic
if f.file_sheet_mnemonic = 'FTDRY_TRS' then
perform fw_core.fn_get_function_exception('staging2.fn_FTDRY_TRS_TRX('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'FTDRY_SUM' then
perform fw_core.fn_get_function_exception('staging2.fn_FTDRY_SUM_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'FTWET_TRS' then
perform fw_core.fn_get_function_exception('staging2.fn_ftwet_trs_TRX('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'FTWET_SUM' then
perform fw_core.fn_get_function_exception('staging2.fn_FTWET_SUM_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'FTHLG_TRS' then
perform fw_core.fn_get_function_exception('staging2.fn_FTHLG_TRS_TRX('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'FTHLG_SUM' then
perform fw_core.fn_get_function_exception('staging2.fn_FTHLG_SUM_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'DBSTD_TEST' then
perform fw_core.fn_get_function_exception('staging2.fn_dbstd_test_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'DBOECD_TEST' then
perform fw_core.fn_get_function_exception('staging2.fn_dboecd_test_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic in ('PTOBEN_PRFN','PTOBEN_PRFE','PTOBEN_PRFB','PTOSTD_PRF') then
perform fw_core.fn_get_function_exception('staging2.fn_PTO_PRF_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic in ('PTOBEN_MPM','PTOSTD_MPM') then
perform fw_core.fn_get_function_exception('staging2.fn_PTO_MPM_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic in ('PTOBEN_GVG','PTOSTD_GVG') then
perform fw_core.fn_get_function_exception('staging2.fn_PTO_GVG_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_BRK' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_BRK_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_FLD' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_FLD_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_HDL' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_HDL_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_NMT' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_NMT_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_HLG' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_HLG_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_PTO' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_PTO_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_VMT' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_VMT_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_ARC' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_ARC_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_DBP' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_DBP_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'BUDNI_LCG' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_LCG_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTCGM_CGM' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTCGM_CGM_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTEMT_STD' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTEMT_STD_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTEMT_EMT' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTEMT_EMT_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTHAM_HAM' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTHAM_HAM_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTHLS_HLS' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTHLS_HLS_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTNST_NST' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTNST_NST_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTSLL_SLL' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTSLL_SLL_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTBT30_BT30' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTBT30_BT30_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTBT50_BT50' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTBT50_BT50_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_sheet_mnemonic = 'IHTBTD_BTD' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTBTD_BTD_TRX ('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''|| f.file_sheet_mnemonic||''','||f.file_syspk||')');
else perform fw_core.fn_insert_db_error ( w_client_id, w_function_id, 1001, 'Compegence', f.file_syspk ,f.file_mnemonic, f.file_sheet_mnemonic ,null,'TRX wrapper', 'unknown TRX', null, 'no script found', null, null, null,'error');
end if;
-- check if transactional script ran correctly and update fw_jobctl_file_sheet_runschedule table.
select e.status from fw_core.db_run_status e where file_syspk = f.file_syspk and file_sheet_mnemonic =f.file_sheet_mnemonic and staging_type = 'trx' order by error_timestamp desc into TRX_status;
if TRX_status = 'success' then
update fw_core.fw_jobctl_file_sheet_runschedule set end_status_note = 'TRX_completed', end_status='success',staging_type = 'trx',end_time = now()
--(select e.error_timestamp from fw_core.db_run_status e where e.file_syspk=f.file_syspk and e.file_sheet_mnemonic =f.file_sheet_mnemonic and e.staging_type = 'trx' order by e.error_timestamp desc limit 1)
where file_syspk=f.file_syspk and file_sheet_mnemonic =f.file_sheet_mnemonic;
else
update fw_core.fw_jobctl_file_sheet_runschedule set end_status_note = 'TRX_failed', end_status='error',staging_type = 'trx',end_time = now()
--(select e.error_timestamp from fw_core.db_run_status e where e.file_syspk=f.file_syspk and e.file_sheet_mnemonic =f.file_sheet_mnemonic and e.staging_type = 'trx' order by e.error_timestamp desc limit 1)
where file_syspk=f.file_syspk and file_sheet_mnemonic =f.file_sheet_mnemonic;
--if error occured store in err_file_syspk variable and go to next file in loop
err_file_syspk := f.file_syspk;
continue;
end if;
end if;
end loop;
-- update fw_jobctl_file_runschedule table.
update fw_core.fw_jobctl_file_runschedule set end_status_note = 'stg2_failed', end_status='error',staging_type = 'stg2',end_time=now() from fw_core.fw_jobctl_file_sheet_runschedule a
where a.latest_runschedule_flag = '1' and a.end_status = 'error' and a.end_status_note = 'stg2_failed' and fw_core.fw_jobctl_file_runschedule.file_syspk = a.file_syspk;
update fw_core.fw_jobctl_file_runschedule set end_status_note = 'TRX_completed', end_status='success',staging_type = 'trx',end_time=now() from fw_core.fw_jobctl_file_sheet_runschedule a
where a.latest_runschedule_flag = '1' and a.end_status = 'success' and a.end_status_note ='TRX_completed' and fw_core.fw_jobctl_file_runschedule.file_syspk = a.file_syspk;
update fw_core.fw_jobctl_file_runschedule set end_status_note = 'TRX_failed', end_status='error',staging_type = 'trx' ,end_time=now() from fw_core.fw_jobctl_file_sheet_runschedule a
where a.latest_runschedule_flag = '1' and a.end_status = 'error' and a.end_status_note = 'TRX_failed' and fw_core.fw_jobctl_file_runschedule.file_syspk = a.file_syspk;
-- update fw_jobctl_runschedule_jobstep table.
SELECT SUM (case WHEN end_status = 'success' THEN 1
ELSE 0 END) AS "Success Sum" FROM fw_core.fw_jobctl_file_runschedule where latest_runschedule_flag = '1' INTO success_sum;
if (success_sum > 0 or success_sum is null) then
update fw_core.fw_jobctl_runschedule_jobstep set end_status_note = 'trx_completed', end_status='success', end_time=now() where job_id = w_job_id and step_id = w_step_id and latest_runschedule_flag = '1';
else
update fw_core.fw_jobctl_runschedule_jobstep set end_status_note = 'trx_failed', end_status='error', end_time=now() where job_id = w_job_id and step_id = w_step_id and latest_runschedule_flag = '1';
end if;
--insert into fw_core.track_jobstep select *,'master_wrapper' from fw_core.fw_jobctl_runschedule_jobstep;
--insert into fw_core.track_file select *,'mater_wrapper' from fw_core.fw_jobctl_file_runschedule;
--insert into fw_core.track_file_sheet select *,'master_wrapper' from fw_core.fw_jobctl_file_sheet_runschedule;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,66 @@
drop function if exists staging2.fn_BUDNI_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_BUDNI_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select distinct a.file_syspk
from fw_core.fw_jobctl_file_runschedule a
where end_status like 'stg1-completed' and file_mnemonic='BUDNI'
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_ARC_Block(20,1,''BUDNI'',''BUDNI_ARC'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='BUDNI_ARC' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_ARC_TRX(20,1,''BUDNI'',''BUDNI_ARC'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_BRK_Block (20,1,''BUDNI'',''BUDNI_BRK'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='BUDNI_BRK' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_BRK_TRX(20,1,''BUDNI'',''BUDNI_BRK'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_DBP_Block (20,1,''BUDNI'',''BUDNI_DBP'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='BUDNI_DBP' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_DBP_TRX(20,1,''BUDNI'',''BUDNI_DBP'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_FLD_Block (20,1,''BUDNI'',''BUDNI_FLD'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='BUDNI_FLD' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_FLD_TRX(20,1,''BUDNI'',''BUDNI_FLD'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_HDL_Block(20,1,''BUDNI'',''BUDNI_HDL'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='BUDNI_HDL' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_HDL_TRX(20,1,''BUDNI'',''BUDNI_HDL'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_HLG_Block(20,1,''BUDNI'',''BUDNI_HLG'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='BUDNI_HLG' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_HLG_TRX(20,1,''BUDNI'',''BUDNI_HLG'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_LCG_Block(20,1,''BUDNI'',''BUDNI_LCG'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='BUDNI_LCG' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_LCG_TRX(20,1,''BUDNI'',''BUDNI_LCG'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_NMT_Block(20,1,''BUDNI'',''BUDNI_NMT'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='BUDNI_NMT' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_NMT_TRX(20,1,''BUDNI'',''BUDNI_NMT'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_PTO_Block(20,1,''BUDNI'',''BUDNI_PTO'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='BUDNI_PTO' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_PTO_TRX(20,1,''BUDNI'',''BUDNI_PTO'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_VMT_Block(20,1,''BUDNI'',''BUDNI_VMT'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='BUDNI_VMT' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_BUDNI_VMT_TRX(20,1,''BUDNI'',''BUDNI_VMT'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,20 @@
drop function if exists staging2.fn_DBOECD_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_DBOECD_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic='DBOECD'
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_dboecd_test_block(20,1,''DBOECD'',''DBOECD_TEST'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='DBOECD_TEST' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_dboecd_test_trx(20,1,''DBOECD'',''DBOECD_TEST'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,20 @@
drop function if exists staging2.fn_DBSTD_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_DBSTD_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic='DBSTD'
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_dbstd_test_block(20,1,''DBSTD'',''DBSTD_TEST'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='DBSTD_TEST' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_dbstd_test_trx(20,1,''DBSTD'',''DBSTD_TEST'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,25 @@
drop function if exists staging2.fn_FTDRY_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_FTDRY_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic='FTDRY'
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_FTDRY_TRS_Block(20,1,''FTDRY'',''FTDRY_TRS'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='FTDRY_TRS' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_FTDRY_TRS_TRX(20,1,''FTDRY'',''FTDRY_TRS'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_FTDRY_SUM_Block (20,1,''FTDRY'',''FTDRY_SUM'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='FTDRY_SUM' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_FTDRY_SUM_TRX(20,1,''FTDRY'',''FTDRY_SUM'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,25 @@
drop function if exists staging2.fn_FTHLG_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_FTHLG_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic='FTHLG'
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_FTHLG_TRS_Block(20,1,''FTHLG'',''FTHLG_TRS'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='FTHLG_TRS' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_FTHLG_TRS_TRX(20,1,''FTHLG'',''FTHLG_TRS'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_FTHLG_SUM_Block (20,1,''FTHLG'',''FTHLG_SUM'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='FTHLG_SUM' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_FTHLG_SUM_TRX(20,1,''FTHLG'',''FTHLG_SUM'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,25 @@
drop function if exists staging2.fn_FTWET_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_FTWET_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic='FTWET'
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_ftwet_trs_block(20,1,''FTWET'',''FTWET_TRS'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='FTWET_TRS' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_FTWET_TRS_TRX(20,1,''FTWET'',''FTWET_TRS'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_ftwet_sum_block (20,1,''FTWET'',''FTWET_SUM'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='FTWET_SUM' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_FTWET_SUM_TRX(20,1,''FTWET'',''FTWET_SUM'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,21 @@
drop function if exists staging2.fn_IHTBT30_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_IHTBT30_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic = 'IHTBT30' order by file_syspk
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_IHTBT30_BT30_Block(20,1,''IHTBT30'',''IHTBT30_BT30'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='IHTBT30_BT30' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTBT30_BT30_TRX(20,1,''IHTBT30'',''IHTBT30_BT30'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,21 @@
drop function if exists staging2.fn_IHTBT50_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_IHTBT50_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic = 'IHTBT50' order by file_syspk
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_IHTBT50_BT50_Block(20,1,''IHTBT50'',''IHTBT50_BT50'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='IHTBT50_BT50' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTBT50_BT50_TRX(20,1,''IHTBT50'',''IHTBT50_BT50'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,22 @@
drop function if exists staging2.fn_IHTBTD_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_IHTBTD_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic = 'IHTBTD' order by file_syspk
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_IHTBTD_BTD_Block(20,1,''IHTBTD'',''IHTBTD_BTD'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='IHTBTD_BTD'
order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTBTD_BTD_TRX(20,1,''IHTBTD'',''IHTBTD_BTD'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,22 @@
drop function if exists staging2.fn_IHTCGM_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_IHTCGM_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic = 'IHTCGM' order by file_syspk
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_IHTCGM_CGM_Block(20,1,''IHTCGM'',''IHTCGM_CGM'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='IHTCGM_CGM'
order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTCGM_CGM_TRX(20,1,''IHTCGM'',''IHTCGM_CGM'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,26 @@
drop function if exists staging2.fn_IHTEMT_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_IHTEMT_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic = 'IHTEMT' order by file_syspk
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_IHTEMT_EMT_Block(20,1,''IHTEMT'',''IHTEMT_EMT'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='IHTEMT_EMT' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTEMT_EMT_TRX(20,1,''IHTEMT'',''IHTEMT_EMT'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_IHTEMT_STD_Block(20,1,''IHTEMT'',''IHTEMT_STD'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='IHTEMT_STD' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTEMT_STD_TRX(20,1,''IHTEMT'',''IHTEMT_STD'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,22 @@
drop function if exists staging2.fn_IHTHAM_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_IHTHAM_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic = 'IHTHAM' order by file_syspk
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_IHTHAM_HAM_Block(20,1,''IHTHAM'',''IHTHAM_HAM'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='IHTHAM_HAM'
order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTHAM_HAM_TRX(20,1,''IHTHAM'',''IHTHAM_HAM'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,21 @@
drop function if exists staging2.fn_IHTHSL_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_IHTHSL_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic = 'IHTHSL' order by file_syspk
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_IHTHSL_HSL_Block(20,1,''IHTHSL'',''IHTHSL_HSL'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='IHTHSL_HSL' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTHSL_HSL_TRX(20,1,''IHTHSL'',''IHTHSL_HSL'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,21 @@
drop function if exists staging2.fn_IHTNST_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_IHTNST_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic = 'IHTNST' order by file_syspk
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_IHTNST_NST_Block(20,1,''IHTNST'',''IHTNST_NST'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='IHTNST_NST' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTNST_NST_TRX(20,1,''IHTNST'',''IHTNST_NST'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,20 @@
drop function if exists staging2.fn_IHTSLL_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_IHTSLL_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic = 'IHTSLL' order by file_syspk
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_IHTSLL_SLL_Block(20,1,''IHTSLL'',''IHTSLL_SLL'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='IHTSLL_SLL' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_IHTSLL_SLL_TRX(20,1,''IHTSLL'',''IHTSLL_SLL'','||w_file_syspk||')'); end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,40 @@
drop function if exists staging2.fn_PTOBEN_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_PTOBEN_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic='PTOBEN'
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_PTO_PRF_block(20,1,''PTOBEN'',''PTOBEN_PRFN'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='PTOBEN_PRFN' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_PTO_PRF_TRX(20,1,''PTOBEN'',''PTOBEN_PRFN'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_PTO_PRF_block(20,1,''PTOBEN'',''PTOBEN_PRFB'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='PTOBEN_PRFB' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_PTO_PRF_TRX(20,1,''PTOBEN'',''PTOBEN_PRFB'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_PTO_PRF_block(20,1,''PTOBEN'',''PTOBEN_PRFE'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='PTOBEN_PRFE' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_PTO_PRF_TRX(20,1,''PTOBEN'',''PTOBEN_PRFE'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_PTO_MPM_block(20,1,''PTOBEN'',''PTOBEN_MPM'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='PTOBEN_MPM' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_PTO_MPM_TRX(20,1,''PTOBEN'',''PTOBEN_MPM'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_PTO_GVG_block(20,1,''PTOBEN'',''PTOBEN_GVG'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='PTOBEN_GVG' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_PTO_GVG_TRX(20,1,''PTOBEN'',''PTOBEN_GVG'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,30 @@
drop function if exists staging2.fn_PTOSTD_RUN;
CREATE OR REPLACE FUNCTION staging2.fn_PTOSTD_RUN()
RETURNS void AS $$
declare
f record;
w_file_syspk int;
status text;
begin
for f in select file_syspk from fw_core.fw_jobctl_file_runschedule
where end_status like 'stg1-completed' and file_mnemonic='PTOSTD'
loop
select f.file_syspk into w_file_syspk;
perform fw_core.fn_get_function_exception('staging2.fn_PTO_PRF_block(20,1,''PTOSTD'',''PTOSTD_PRF'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='PTOSTD_PRF' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_PTO_PRF_TRX(20,1,''PTOSTD'',''PTOSTD_PRF'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_PTO_MPM_block(20,1,''PTOSTD'',''PTOSTD_MPM'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='PTOSTD_MPM' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_PTO_MPM_TRX(20,1,''PTOSTD'',''PTOSTD_MPM'','||w_file_syspk||')');
end if;
perform fw_core.fn_get_function_exception('staging2.fn_PTO_GVG_block(20,1,''PTOSTD'',''PTOSTD_GVG'','||w_file_syspk||')');
select e.status from fw_core.db_run_status e where file_syspk = w_file_syspk and file_sheet_mnemonic ='PTOSTD_GVG' order by error_timestamp desc into status;
if status = 'success' then
perform fw_core.fn_get_function_exception('staging2.fn_PTO_GVG_TRX(20,1,''PTOSTD'',''PTOSTD_GVG'','||w_file_syspk||')');
end if;
end loop;
end;
$$ LANGUAGE plpgsql;