Files
MMT/MMT_latest_version/sql/onetime/wrappers/wrapper_IHTCGM.sql
2021-06-21 12:35:07 +05:30

23 lines
932 B
PL/PgSQL

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;