
--drop function if exists fw_core.fn_check_count();

CREATE or REPLACE FUNCTION fw_core.fn_check_count(p_date date)
 RETURNS void
 LANGUAGE plpgsql
AS $function$


   declare __client_id int :=21;
   declare __function_id int :=1;
   declare __file_mnemonic text  := null;
   declare __file_sheet_mnemonic text :=null;
   declare __file_syspk int := null;
   declare err_state   text;
   declare err_msg      text;
   declare err_detail  text;
   declare err_hint   text;
   declare err_context text;  

   begin
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'budni_brake_perf_parking_brake_test_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.budni_brake_perf_parking_brake_test_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'budni_brake_perf_service_brake_test_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.budni_brake_perf_service_brake_test_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'budni_centre_of_gravity_location',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.budni_centre_of_gravity_location a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'budni_drawbar_perf_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.budni_drawbar_perf_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'budni_field_perf_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.budni_field_perf_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'budni_haulage_perf_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.budni_haulage_perf_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'budni_hydraulic_lifting_capacity_test_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.budni_hydraulic_lifting_capacity_test_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model; 
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'budni_hydraulic_maint_of_lift_load_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.budni_hydraulic_maint_of_lift_load_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'budni_hydraulic_power_test_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.budni_hydraulic_power_test_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'budni_noise_atmospheric_conditions',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.budni_noise_atmospheric_conditions a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'budni_noise_measurement_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.budni_noise_measurement_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'budni_pto_perf_results_details',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.budni_pto_perf_results_details a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'budni_pto_perf_results_summary',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.budni_pto_perf_results_summary a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'budni_test_observations',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.budni_test_observations a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'budni_vibration_measurement',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.budni_vibration_measurement a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'drawbar_perf_observations',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.drawbar_perf_observations a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'drawbar_perf_oecd_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.drawbar_perf_oecd_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'drawbar_perf_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.drawbar_perf_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'drawbar_perf_results_summary',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.drawbar_perf_results_summary a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'field_perf_summary',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.field_perf_summary a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
--insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'field_perf_summary_implement_info',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.field_perf_summary_implement_info a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'field_perf_summary_tractor_info',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.field_perf_summary_tractor_info a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
--insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'field_perf_summary_trailer_info',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.field_perf_summary_trailer_info a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_brake_pedal_effort',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_brake_pedal_effort a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_brake_perf_test_condition',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_brake_perf_test_condition a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_brake_perf_test_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_brake_perf_test_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_cgm_lifting_angle_load_details',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_cgm_lifting_angle_load_details a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_cgm_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_cgm_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_clutch_pedal_effort',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_clutch_pedal_effort a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_gear_effort',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_gear_effort a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_gear_max_speed',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_gear_max_speed a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_hot_air_mapping_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_hot_air_mapping_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_hyd_lift_sensitivity',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_hyd_lift_sensitivity a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_noise_measurement_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_noise_measurement_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_noise_measurement_test',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_noise_measurement_test a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_pedal_effort',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_pedal_effort a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_speed_lead_lag_measurement',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_speed_lead_lag_measurement a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_steering_effort',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_steering_effort a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'iht_steering_effort_raw_data',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.iht_steering_effort_raw_data a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'pto_engine_oil_consumption',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.pto_engine_oil_consumption a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'pto_key_perf_parameters',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.pto_key_perf_parameters a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'pto_multipoint_mapping',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.pto_multipoint_mapping a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'pto_perf_governing_graph',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.pto_perf_governing_graph a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'pto_perf_results',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.pto_perf_results a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'pto_smoke_test',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.pto_smoke_test a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance_atmospheric_info',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance_atmospheric_info a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance_drawbar_info',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance_drawbar_info a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance_engine_info',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance_engine_info a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance_equipment_info',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance_equipment_info a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance_fuel_lubricant_info',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance_fuel_lubricant_info a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance_gear_speed_chart',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance_gear_speed_chart a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
--insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance_images',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance_images a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
--insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance_implement_info',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance_implement_info a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance_measurement_uncertainty',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance_measurement_uncertainty a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance_tractor_info',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance_tractor_info a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance_tractor_info_misc',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance_tractor_info_misc a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
--insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance_trailer_info',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance_trailer_info a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance_tyre_info',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance_tyre_info a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance_weight_reaction',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance_weight_reaction a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;
insert into fw_core.check_model_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,tractor_name,row_count) select 'test_instance_wheels_info',file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model,count(*) from transactional.test_instance_wheels_info a where a.create_timestamp::timestamp::date =p_date group by file_syspk,file_mnemonic,file_sheet_mnemonic,tractor_model;



insert into fw_core.check_mnemonic_count(table_name,syspks,file_mnemonic,file_sheet_mnemonic,row_count) 
SELECT table_name, syspks, file_mnemonic, file_sheet_mnemonic,sum(row_count)
FROM fw_core.check_model_count
where create_timestamp::date=p_date 
group by table_name, syspks, file_mnemonic, file_sheet_mnemonic;


 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_arc_perf_atmos_meas_test_block',count(*) from staging2.budni_arc_perf_atmos_meas_test_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_arc_spec_h1_block',count(*) from staging2.budni_arc_spec_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_arc_test_obs_summary_block',count(*) from staging2.budni_arc_test_obs_summary_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_brk_other_observations_block',count(*) from staging2.budni_brk_other_observations_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_brk_parking_barke_test_block',count(*) from staging2.budni_brk_parking_barke_test_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_brk_service_cold_ballasted_25kmph_block',count(*) from staging2.budni_brk_service_cold_ballasted_25kmph_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_brk_service_cold_ballasted_maximum_block',count(*) from staging2.budni_brk_service_cold_ballasted_maximum_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_brk_service_cold_standard_25kmph_block',count(*) from staging2.budni_brk_service_cold_standard_25kmph_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_brk_service_cold_standard_maximum_block',count(*) from staging2.budni_brk_service_cold_standard_maximum_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_brk_service_fade_ballasted_25kmph_block',count(*) from staging2.budni_brk_service_fade_ballasted_25kmph_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_brk_service_fade_standard_maximum_block',count(*) from staging2.budni_brk_service_fade_standard_maximum_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_brk_spec_h1_block',count(*) from staging2.budni_brk_spec_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_brk_test_obs_summary_block',count(*) from staging2.budni_brk_test_obs_summary_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_dbp_drawbar_perf_block',count(*) from staging2.budni_dbp_drawbar_perf_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_dbp_spec_h1_block',count(*) from staging2.budni_dbp_spec_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_fld_cage_wheel_block',count(*) from staging2.budni_fld_cage_wheel_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_fld_impl_test_block',count(*) from staging2.budni_fld_impl_test_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_fld_spec_h1_block',count(*) from staging2.budni_fld_spec_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_fld_sum_perf_test_block',count(*) from staging2.budni_fld_sum_perf_test_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_fld_test_obs_summary_block',count(*) from staging2.budni_fld_test_obs_summary_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_hdl_lifting_capacity_test_block',count(*) from staging2.budni_hdl_lifting_capacity_test_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_hdl_maintenance_of_lift_load_block',count(*) from staging2.budni_hdl_maintenance_of_lift_load_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_hdl_power_test_block',count(*) from staging2.budni_hdl_power_test_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_hdl_spec_h1_block',count(*) from staging2.budni_hdl_spec_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_hdl_test_obs_summary_block',count(*) from staging2.budni_hdl_test_obs_summary_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_hlg_perf_test_block',count(*) from staging2.budni_hlg_perf_test_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_hlg_spec_h1_block',count(*) from staging2.budni_hlg_spec_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_hlg_test_obs_summary_block',count(*) from staging2.budni_hlg_test_obs_summary_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_lcg_gravity_test_block',count(*) from staging2.budni_lcg_gravity_test_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_lcg_spec_h1_block',count(*) from staging2.budni_lcg_spec_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_nmt_atmos_cond_2_block',count(*) from staging2.budni_nmt_atmos_cond_2_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_nmt_meas_results_1_block',count(*) from staging2.budni_nmt_meas_results_1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_nmt_meas_results_2_block',count(*) from staging2.budni_nmt_meas_results_2_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_nmt_noise_at_bystander_position_block',count(*) from staging2.budni_nmt_noise_at_bystander_position_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_nmt_noise_at_operator_ear_level_block',count(*) from staging2.budni_nmt_noise_at_operator_ear_level_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_nmt_spec_h1_block',count(*) from staging2.budni_nmt_spec_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_nmt_test_obs_summary_block',count(*) from staging2.budni_nmt_test_obs_summary_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','[REDACTED]',count(*) from staging2.budni_pto_mmtkeyword1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','[REDACTED]',count(*) from staging2.budni_pto_mmtkeyword2_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_pto_perf_report_block',count(*) from staging2.budni_pto_perf_report_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_pto_spec_h1_block',count(*) from staging2.budni_pto_spec_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_pto_summary_block',count(*) from staging2.budni_pto_summary_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_vmt_perf_meas_test_block',count(*) from staging2.budni_vmt_perf_meas_test_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_vmt_spec_h1_block',count(*) from staging2.budni_vmt_spec_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','budni_vmt_test_obs_summary_block',count(*) from staging2.budni_vmt_test_obs_summary_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_drawbar_performance_fuel_consumption_block',count(*) from staging2.dboecd_test_drawbar_performance_fuel_consumption_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_drawbar_performance_gear_performance_block',count(*) from staging2.dboecd_test_drawbar_performance_gear_performance_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_drawbar_performance_selected_summary_block',count(*) from staging2.dboecd_test_drawbar_performance_selected_summary_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_engine_rpm_engine_to_pto_block',count(*) from staging2.dboecd_test_engine_rpm_engine_to_pto_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_engine_rpm_required_pull_block',count(*) from staging2.dboecd_test_engine_rpm_required_pull_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_engine_rpm_rpm_block',count(*) from staging2.dboecd_test_engine_rpm_rpm_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_engine_rpm_tyre_details_block',count(*) from staging2.dboecd_test_engine_rpm_tyre_details_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_engine_rpm_weight_block',count(*) from staging2.dboecd_test_engine_rpm_weight_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_h1_block',count(*) from staging2.dboecd_test_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_measurement_uncertainty_block',count(*) from staging2.dboecd_test_measurement_uncertainty_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_remarks_block',count(*) from staging2.dboecd_test_remarks_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_remarks_footer_block',count(*) from staging2.dboecd_test_remarks_footer_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_test_condition_block',count(*) from staging2.dboecd_test_test_condition_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_test_equipment_used_block',count(*) from staging2.dboecd_test_test_equipment_used_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_tractor_specifications_cleaner_block',count(*) from staging2.dboecd_test_tractor_specifications_cleaner_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_tractor_specifications_cylinders_block',count(*) from staging2.dboecd_test_tractor_specifications_cylinders_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_tractor_specifications_engine_details_block',count(*) from staging2.dboecd_test_tractor_specifications_engine_details_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_tractor_specifications_fuel_and_injection_block',count(*) from staging2.dboecd_test_tractor_specifications_fuel_and_injection_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_transmission_clutch_block',count(*) from staging2.dboecd_test_transmission_clutch_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_transmission_drawbar_block',count(*) from staging2.dboecd_test_transmission_drawbar_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_transmission_fuel_lubricant_block',count(*) from staging2.dboecd_test_transmission_fuel_lubricant_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_transmission_speed_chart_block',count(*) from staging2.dboecd_test_transmission_speed_chart_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_transmission_speed_chart_desc_block',count(*) from staging2.dboecd_test_transmission_speed_chart_desc_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dboecd_test_transmission_wheels_block',count(*) from staging2.dboecd_test_transmission_wheels_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_drawbar_performance_gear_performance_block',count(*) from staging2.dbstd_test_drawbar_performance_gear_performance_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_drawbar_performance_selected_summary_block',count(*) from staging2.dbstd_test_drawbar_performance_selected_summary_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_engine_rpm_engine_to_pto_block',count(*) from staging2.dbstd_test_engine_rpm_engine_to_pto_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_engine_rpm_required_pull_block',count(*) from staging2.dbstd_test_engine_rpm_required_pull_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_engine_rpm_rpm_block',count(*) from staging2.dbstd_test_engine_rpm_rpm_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_engine_rpm_tyre_details_block',count(*) from staging2.dbstd_test_engine_rpm_tyre_details_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_engine_rpm_weight_block',count(*) from staging2.dbstd_test_engine_rpm_weight_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_h1_block',count(*) from staging2.dbstd_test_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_measurement_uncertainty_block',count(*) from staging2.dbstd_test_measurement_uncertainty_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_remarks_block',count(*) from staging2.dbstd_test_remarks_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_remarks_footer_block',count(*) from staging2.dbstd_test_remarks_footer_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_test_condition_block',count(*) from staging2.dbstd_test_test_condition_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_test_equipment_used_block',count(*) from staging2.dbstd_test_test_equipment_used_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_tractor_specifications_cleaner_block',count(*) from staging2.dbstd_test_tractor_specifications_cleaner_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_tractor_specifications_cylinders_block',count(*) from staging2.dbstd_test_tractor_specifications_cylinders_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_tractor_specifications_engine_details_block',count(*) from staging2.dbstd_test_tractor_specifications_engine_details_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_tractor_specifications_fuel_and_injection_block',count(*) from staging2.dbstd_test_tractor_specifications_fuel_and_injection_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_transmission_clutch_block',count(*) from staging2.dbstd_test_transmission_clutch_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_transmission_drawbar_block',count(*) from staging2.dbstd_test_transmission_drawbar_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_transmission_fuel_lubricant_block',count(*) from staging2.dbstd_test_transmission_fuel_lubricant_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_transmission_speed_chart_block',count(*) from staging2.dbstd_test_transmission_speed_chart_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_transmission_speed_chart_desc_block',count(*) from staging2.dbstd_test_transmission_speed_chart_desc_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','dbstd_test_transmission_wheels_block',count(*) from staging2.dbstd_test_transmission_wheels_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftdry_sum_comments_by_block',count(*) from staging2.ftdry_sum_comments_by_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftdry_sum_implement_block',count(*) from staging2.ftdry_sum_implement_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftdry_sum_test_condition_1_block',count(*) from staging2.ftdry_sum_test_condition_1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftdry_sum_test_condition_2_block',count(*) from staging2.ftdry_sum_test_condition_2_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftdry_sum_trac_h1_block',count(*) from staging2.ftdry_sum_trac_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftdry_trs_engine_rpm_block',count(*) from staging2.ftdry_trs_engine_rpm_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftdry_trs_h1_block',count(*) from staging2.ftdry_trs_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftdry_trs_implement_block',count(*) from staging2.ftdry_trs_implement_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftdry_trs_spec_block',count(*) from staging2.ftdry_trs_spec_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','fthlg_sum_comments_by_block',count(*) from staging2.fthlg_sum_comments_by_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','fthlg_sum_test_condition_1_block',count(*) from staging2.fthlg_sum_test_condition_1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','fthlg_sum_test_condition_2_block',count(*) from staging2.fthlg_sum_test_condition_2_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','fthlg_sum_trac_h1_block',count(*) from staging2.fthlg_sum_trac_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','fthlg_sum_trail_type_block',count(*) from staging2.fthlg_sum_trail_type_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','fthlg_trs_engine_rpm_block',count(*) from staging2.fthlg_trs_engine_rpm_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','fthlg_trs_h1_block',count(*) from staging2.fthlg_trs_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','fthlg_trs_spec_block',count(*) from staging2.fthlg_trs_spec_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','fthlg_trs_trailer_block',count(*) from staging2.fthlg_trs_trailer_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftwet_sum_cage_wheel_block',count(*) from staging2.ftwet_sum_cage_wheel_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftwet_sum_comments_by_block',count(*) from staging2.ftwet_sum_comments_by_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftwet_sum_implement_block',count(*) from staging2.ftwet_sum_implement_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftwet_sum_test_condition_block',count(*) from staging2.ftwet_sum_test_condition_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftwet_sum_trac_h1_block',count(*) from staging2.ftwet_sum_trac_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftwet_trs_engine_rpm_block',count(*) from staging2.ftwet_trs_engine_rpm_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftwet_trs_h1_block',count(*) from staging2.ftwet_trs_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftwet_trs_implement_block',count(*) from staging2.ftwet_trs_implement_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ftwet_trs_spec_block',count(*) from staging2.ftwet_trs_spec_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt30_bt30_footer_block',count(*) from staging2.ihtbt30_bt30_footer_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt30_bt30_h1_block',count(*) from staging2.ihtbt30_bt30_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt30_bt30_test_condition_block',count(*) from staging2.ihtbt30_bt30_test_condition_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt30_bt30_test_res_1_block',count(*) from staging2.ihtbt30_bt30_test_res_1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt30_bt30_test_res_2_block',count(*) from staging2.ihtbt30_bt30_test_res_2_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt30_bt30_test_res_3_block',count(*) from staging2.ihtbt30_bt30_test_res_3_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt30_bt30_test_res_4_block',count(*) from staging2.ihtbt30_bt30_test_res_4_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt30_bt30_tyre_details_block',count(*) from staging2.ihtbt30_bt30_tyre_details_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt30_bt30_weight_block',count(*) from staging2.ihtbt30_bt30_weight_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt50_bt50_footer_block',count(*) from staging2.ihtbt50_bt50_footer_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt50_bt50_h1_block',count(*) from staging2.ihtbt50_bt50_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt50_bt50_test_condition_block',count(*) from staging2.ihtbt50_bt50_test_condition_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt50_bt50_test_res_1_block',count(*) from staging2.ihtbt50_bt50_test_res_1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt50_bt50_test_res_2_block',count(*) from staging2.ihtbt50_bt50_test_res_2_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt50_bt50_test_res_3_block',count(*) from staging2.ihtbt50_bt50_test_res_3_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt50_bt50_test_res_4_block',count(*) from staging2.ihtbt50_bt50_test_res_4_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt50_bt50_tyre_details_block',count(*) from staging2.ihtbt50_bt50_tyre_details_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbt50_bt50_weight_block',count(*) from staging2.ihtbt50_bt50_weight_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbtd_btd_footer_block',count(*) from staging2.ihtbtd_btd_footer_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbtd_btd_h1_block',count(*) from staging2.ihtbtd_btd_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbtd_btd_test_condition_block',count(*) from staging2.ihtbtd_btd_test_condition_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbtd_btd_test_res_1_block',count(*) from staging2.ihtbtd_btd_test_res_1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbtd_btd_test_res_2_block',count(*) from staging2.ihtbtd_btd_test_res_2_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbtd_btd_test_res_3_block',count(*) from staging2.ihtbtd_btd_test_res_3_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbtd_btd_test_res_4_block',count(*) from staging2.ihtbtd_btd_test_res_4_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbtd_btd_test_res_5_block',count(*) from staging2.ihtbtd_btd_test_res_5_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbtd_btd_test_res_6_block',count(*) from staging2.ihtbtd_btd_test_res_6_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbtd_btd_tyre_details_block',count(*) from staging2.ihtbtd_btd_tyre_details_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtbtd_btd_weight_block',count(*) from staging2.ihtbtd_btd_weight_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtcgm_cgm_footer_block',count(*) from staging2.ihtcgm_cgm_footer_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtcgm_cgm_h1_block',count(*) from staging2.ihtcgm_cgm_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtcgm_cgm_lifting_block',count(*) from staging2.ihtcgm_cgm_lifting_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtcgm_cgm_results_block',count(*) from staging2.ihtcgm_cgm_results_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtcgm_cgm_tyre_details_block',count(*) from staging2.ihtcgm_cgm_tyre_details_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtcgm_cgm_weight_block',count(*) from staging2.ihtcgm_cgm_weight_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtcgm_cgm_wheel_block',count(*) from staging2.ihtcgm_cgm_wheel_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtemt_emt_brake_pedal_block',count(*) from staging2.ihtemt_emt_brake_pedal_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtemt_emt_footer_block',count(*) from staging2.ihtemt_emt_footer_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtemt_emt_h1_block',count(*) from staging2.ihtemt_emt_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtemt_emt_pedal_block',count(*) from staging2.ihtemt_emt_pedal_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtemt_emt_steering_block',count(*) from staging2.ihtemt_emt_steering_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtemt_emt_tyre_details_block',count(*) from staging2.ihtemt_emt_tyre_details_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtemt_emt_weight_block',count(*) from staging2.ihtemt_emt_weight_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtemt_emt_wheel_block',count(*) from staging2.ihtemt_emt_wheel_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtemt_std_raw_data_block',count(*) from staging2.ihtemt_std_raw_data_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtham_ham_atmos_cond_block',count(*) from staging2.ihtham_ham_atmos_cond_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtham_ham_drawbar_block',count(*) from staging2.ihtham_ham_drawbar_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtham_ham_engine_rpm_block',count(*) from staging2.ihtham_ham_engine_rpm_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtham_ham_footer_block',count(*) from staging2.ihtham_ham_footer_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtham_ham_h1_block',count(*) from staging2.ihtham_ham_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtham_ham_results_block',count(*) from staging2.ihtham_ham_results_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtham_ham_tractor_block',count(*) from staging2.ihtham_ham_tractor_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtham_ham_tyre_details_block',count(*) from staging2.ihtham_ham_tyre_details_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtham_ham_weight_block',count(*) from staging2.ihtham_ham_weight_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihthls_hls_footer_block',count(*) from staging2.ihthls_hls_footer_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihthls_hls_h1_block',count(*) from staging2.ihthls_hls_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihthls_hls_numeric_block',count(*) from staging2.ihthls_hls_numeric_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihthls_hls_tyre_details_block',count(*) from staging2.ihthls_hls_tyre_details_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihthls_hls_weight_block',count(*) from staging2.ihthls_hls_weight_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihthls_hls_wheel_block',count(*) from staging2.ihthls_hls_wheel_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtnst_nst_atmos_cond_block',count(*) from staging2.ihtnst_nst_atmos_cond_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtnst_nst_engine_rpm_block',count(*) from staging2.ihtnst_nst_engine_rpm_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtnst_nst_footer_block',count(*) from staging2.ihtnst_nst_footer_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtnst_nst_h1_block',count(*) from staging2.ihtnst_nst_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtnst_nst_oel_noise_block',count(*) from staging2.ihtnst_nst_oel_noise_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtnst_nst_oel_noise_load_block',count(*) from staging2.ihtnst_nst_oel_noise_load_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtnst_nst_stand_noise_block',count(*) from staging2.ihtnst_nst_stand_noise_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtnst_nst_tyre_details_block',count(*) from staging2.ihtnst_nst_tyre_details_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtnst_nst_weight_block',count(*) from staging2.ihtnst_nst_weight_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtsll_sll_footer_block',count(*) from staging2.ihtsll_sll_footer_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtsll_sll_forward_block',count(*) from staging2.ihtsll_sll_forward_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtsll_sll_h1_block',count(*) from staging2.ihtsll_sll_h1_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtsll_sll_lead_lag_block',count(*) from staging2.ihtsll_sll_lead_lag_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtsll_sll_reverse_block',count(*) from staging2.ihtsll_sll_reverse_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtsll_sll_tyre_details_block',count(*) from staging2.ihtsll_sll_tyre_details_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtsll_sll_weight_block',count(*) from staging2.ihtsll_sll_weight_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ihtsll_sll_wheel_block',count(*) from staging2.ihtsll_sll_wheel_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ptoben_gvg_performance_governing_trails_block',count(*) from staging2.ptoben_gvg_performance_governing_trails_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ptoben_mpm_performance_boost_natural_block',count(*) from staging2.ptoben_mpm_performance_boost_natural_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ptoben_prf_2hrs_max_power_natural_ambient_block',count(*) from staging2.ptoben_prf_2hrs_max_power_natural_ambient_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ptoben_prf_2hrs_max_power_test_high_ambient_block',count(*) from staging2.ptoben_prf_2hrs_max_power_test_high_ambient_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ptoben_prf_engine_oil_consumption_block',count(*) from staging2.ptoben_prf_engine_oil_consumption_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ptoben_prf_key_performance_parameters_block',count(*) from staging2.ptoben_prf_key_performance_parameters_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ptoben_prf_smoke_test_block',count(*) from staging2.ptoben_prf_smoke_test_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ptoben_prf_tractor_specs_block',count(*) from staging2.ptoben_prf_tractor_specs_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ptoben_prf_varying_load_rated_rpm_block',count(*) from staging2.ptoben_prf_varying_load_rated_rpm_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ptoben_prf_varying_load_std_pto_block',count(*) from staging2.ptoben_prf_varying_load_std_pto_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ptoben_prf_varying_speed_natural_ambient_block',count(*) from staging2.ptoben_prf_varying_speed_natural_ambient_block where create_time::date =p_date;
 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count) select 'staging2','ptoben_prf_varying_speed_test_high_ambient_block',count(*) from staging2.ptoben_prf_varying_speed_test_high_ambient_block where create_time::date =p_date;

 insert into fw_core.check_table_stg_trx_count(schema_name,table_name,row_count)
 select 'transactional',table_name, sum(row_count)
 from fw_core.check_model_count
 where create_timestamp::date =p_date
 group by table_name;




    update fw_core.fw_jobctl_runschedule_jobstep set end_status_note = 'check count success', end_status='success',end_time= now() where job_id=7 and step_id=1 and latest_runschedule_flag='1';
perform  fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'Check_Count', 'fn_check_count', err_state, err_msg, err_detail, err_hint, err_context,'success');

EXCEPTION when OTHERS then 

 err_state   = returned_sqlstate, /* P0002 */
       err_msg     = message_text,  /* No Data in FTDRY */
       err_detail  = pg_exception_detail, /* No data in table t_test_new */
       err_hint    = pg_exception_hint, /* No data error capture */
       err_context = pg_exception_context; /* PL/pgSQL function staging2.fn_ftdry_trs_block(integer,integer,text,text,integer) line 69 at RAISE*/

   update fw_core.fw_jobctl_runschedule_jobstep set end_status_note = 'check count failed', end_status='error' ,end_time= now() where job_id=7 and step_id=1 and latest_runschedule_flag='1';

perform  fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'Check_Count', 'fn_check_count', err_state, err_msg, err_detail, err_hint, err_context,'error');



end
$function$
;


