sql
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
|
||||
|
||||
|
||||
drop function if exists fw_core.fn_run_post_generic_validation;
|
||||
CREATE OR REPLACE FUNCTION fw_core.fn_run_post_generic_validation(p_client_id int,p_function_id int,p_job_id int,p_step_id int)
|
||||
RETURNS void AS $$
|
||||
@@ -32,36 +35,47 @@ SELECT SUM (case WHEN end_status = 'success' THEN 1
|
||||
if (success_sum >0 or success_sum is null) then
|
||||
update fw_core.fw_jobctl_runschedule_jobstep set end_status_note = 'generic_validation_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 = 'generic_validation_failed', end_status='error', end_time= now() where job_id = w_job_id and step_id = w_step_id and latest_runschedule_flag = '1';
|
||||
update fw_core.fw_jobctl_runschedule_jobstep set end_status_note = 'generic_validation_failed', end_status='success', end_time= now() where job_id = w_job_id and step_id = w_step_id and latest_runschedule_flag = '1';
|
||||
return ;
|
||||
end if;
|
||||
|
||||
--insert into fw_core.track_jobstep select *,'file_syspk' from fw_core.fw_jobctl_runschedule_jobstep;
|
||||
--insert into fw_core.track_file select *,'file_syspk' from fw_core.fw_jobctl_file_runschedule;
|
||||
--insert into fw_core.track_file_sheet select * ,'file_syspk' from fw_core.fw_jobctl_file_sheet_runschedule;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- validate sheet names for a given file:
|
||||
|
||||
for f in select distinct file_syspk,file_mnemonic,file_sheet_mnemonic from fw_core.fw_jobctl_file_sheet_runschedule
|
||||
for f in select distinct file_syspk,file_mnemonic from fw_core.fw_jobctl_file_sheet_runschedule
|
||||
where file_sheet_mnemonic is not null
|
||||
and end_status != 'error' and end_status_note = 'generic_validation_completed' and latest_runschedule_flag = '1'
|
||||
and end_status != 'error' and end_status_note = 'generic_validation_completed' and latest_runschedule_flag = '1'
|
||||
loop
|
||||
|
||||
|
||||
if f.file_mnemonic = 'BUDNI'
|
||||
then
|
||||
update fw_core.fw_jobctl_file_sheet_runschedule set end_status_note = 'generic_validation_completed', end_status='success', staging_type = 'stg1',end_time = now() where
|
||||
file_syspk = f.file_syspk;
|
||||
update fw_core.fw_jobctl_file_runschedule set end_status_note ='generic_validation_completed', end_status='success', staging_type = 'stg1',end_time = now() where file_syspk = f.file_syspk;
|
||||
|
||||
else
|
||||
|
||||
select count(distinct sheet_name) from fw_core.test_file_sheet_format_master
|
||||
where sheet_name not in
|
||||
(select distinct sheet_name from fw_core.fw_jobctl_file_sheet_runschedule where file_mnemonic in (f.file_mnemonic) and file_sheet_mnemonic is not null and file_syspk=f.file_syspk)
|
||||
(select distinct sheet_name from fw_core.fw_jobctl_file_sheet_runschedule where file_sheet_mnemonic is not null and file_syspk=f.file_syspk)
|
||||
and file_mnemonic in (f.file_mnemonic)
|
||||
into missing_sheet_count;
|
||||
|
||||
if missing_sheet_count = 0 then
|
||||
|
||||
if (missing_sheet_count = 0 ) then
|
||||
update fw_core.fw_jobctl_file_sheet_runschedule set end_status_note = 'generic_validation_completed', end_status='success', staging_type = 'stg1',end_time = now() where
|
||||
file_syspk = f.file_syspk and file_sheet_mnemonic=f.file_sheet_mnemonic;
|
||||
file_syspk = f.file_syspk;
|
||||
update fw_core.fw_jobctl_file_runschedule set end_status_note ='generic_validation_completed', end_status='success', staging_type = 'stg1',end_time = now() where file_syspk = f.file_syspk;
|
||||
|
||||
else
|
||||
update fw_core.fw_jobctl_file_sheet_runschedule set end_status_note = 'stg1_sheet_missing', end_status='error', staging_type = 'stg1',end_time = now() where
|
||||
file_syspk = f.file_syspk and file_sheet_mnemonic=f.file_sheet_mnemonic;
|
||||
file_syspk = f.file_syspk;
|
||||
update fw_core.fw_jobctl_file_runschedule set end_status_note ='generic_validation_failed', end_status='error', staging_type = 'stg1',end_time = now() where file_syspk = f.file_syspk;
|
||||
end if;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
@@ -70,17 +84,12 @@ end if;
|
||||
if ((success_sum > 0) or (success_sum is null)) then
|
||||
update fw_core.fw_jobctl_runschedule_jobstep set end_status_note = 'generic_validation_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 = 'generic_validation_failed', end_status='error', end_time=now() where job_id = w_job_id and step_id = w_step_id and latest_runschedule_flag = '1';
|
||||
update fw_core.fw_jobctl_runschedule_jobstep set end_status_note = 'generic_validation_failed', end_status='success', end_time=now() where job_id = w_job_id and step_id = w_step_id and latest_runschedule_flag = '1';
|
||||
return ;
|
||||
end if;
|
||||
|
||||
|
||||
|
||||
|
||||
insert into fw_core.track_jobstep select *,'missing_sheet' from fw_core.fw_jobctl_runschedule_jobstep;
|
||||
insert into fw_core.track_file select *,'missing_sheet' from fw_core.fw_jobctl_file_runschedule;
|
||||
insert into fw_core.track_file_sheet select * ,'missing_sheet' from fw_core.fw_jobctl_file_sheet_runschedule;
|
||||
|
||||
-- validate keywords for a given file:
|
||||
|
||||
for f in select distinct file_syspk,file_mnemonic,file_sheet_mnemonic
|
||||
@@ -108,35 +117,23 @@ insert into fw_core.track_file_sheet select * ,'missing_sheet' from fw_core.fw_
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
-- update fw_jobctl_file_runschedule table.
|
||||
|
||||
|
||||
--insert into fw_core.track_jobstep select *,'keyword_' from fw_core.fw_jobctl_runschedule_jobstep;
|
||||
--insert into fw_core.track_file select *,'keyword_' from fw_core.fw_jobctl_file_runschedule;
|
||||
--insert into fw_core.track_file_sheet select *,'keyword_' from fw_core.fw_jobctl_file_sheet_runschedule;
|
||||
|
||||
--, staging_type = 'stg1'
|
||||
|
||||
update fw_core.fw_jobctl_file_runschedule set end_status_note = 'generic_validation_completed', end_status='success', 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 ='generic_validation_completed' and fw_core.fw_jobctl_file_runschedule.file_syspk = a.file_syspk;
|
||||
|
||||
update fw_core.fw_jobctl_file_runschedule set end_status_note = 'generic_validation_failed' , end_status='error',end_time=now() from fw_core.fw_jobctl_file_sheet_runschedule a
|
||||
update fw_core.fw_jobctl_file_runschedule set end_status_note = 'validation_failed' , end_status='error',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 = 'stg1_keyword_validation_failed' and fw_core.fw_jobctl_file_runschedule.file_syspk = a.file_syspk;
|
||||
|
||||
update fw_core.fw_jobctl_file_sheet_runschedule set end_status='error',end_status_note = 'stg1_keyword_validation_failed',end_time=now() from fw_core.fw_jobctl_file_runschedule a
|
||||
where file_sheet_mnemonic is not null and a.latest_runschedule_flag = '1' and a.end_status = 'error' and a.end_status_note = 'generic_validation_failed' and fw_core.fw_jobctl_file_sheet_runschedule.file_syspk = a.file_syspk;
|
||||
where file_sheet_mnemonic is not null and a.latest_runschedule_flag = '1' and a.end_status = 'error' and a.end_status_note = 'validation_failed' and fw_core.fw_jobctl_file_sheet_runschedule.file_syspk = a.file_syspk;
|
||||
|
||||
SELECT SUM (case WHEN end_status = 'success' THEN 1
|
||||
ELSE 0 END) AS "Error 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 = 'generic_validation_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 = 'generic_validation_failed', end_status= 'error', end_time=now() where job_id = w_job_id and step_id = w_step_id and latest_runschedule_flag = '1';
|
||||
update fw_core.fw_jobctl_runschedule_jobstep set end_status_note = 'generic_validation_failed', end_status= 'success', 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 *,'keyword_missing' from fw_core.fw_jobctl_runschedule_jobstep;
|
||||
--insert into fw_core.track_file select *,'keyword_missing' from fw_core.fw_jobctl_file_runschedule;
|
||||
--insert into fw_core.track_file_sheet select *,'keyword_missing' from fw_core.fw_jobctl_file_sheet_runschedule;
|
||||
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user