From aa44ad9d0a10e8a2454045e8c14330d42efc1f9f Mon Sep 17 00:00:00 2001 From: Deepthi Date: Mon, 29 Mar 2021 13:25:33 +0530 Subject: [PATCH] added new files from jagadish and vignesh folders --- MMT_SQL/common/config.txt | 145 ++ MMT_SQL/common/delete-ods.txt | 38 + MMT_SQL/ods/BUDNI_DBP_ODS.SQL | 125 -- MMT_SQL/ods/DBOECD-TEST-ods.txt | 759 +++++++ MMT_SQL/ods/DBSTD_TEST_ODS.SQL | 688 ++++++ MMT_SQL/ods/FTDRY_SUM_ODS.sql | 241 --- MMT_SQL/ods/FTHLG_SUM_ODS.sql | 229 -- MMT_SQL/ods/FTHLG_TRS_ODS.sql | 194 -- MMT_SQL/ods/FTWET_SUM_ODS.sql | 185 -- MMT_SQL/ods/FTWET_TRS_ODS.sql | 193 -- MMT_SQL/ods/PTO-GVG_ods.txt | 160 ++ MMT_SQL/ods/PTO-MPM_ods.txt | 34 + MMT_SQL/ods/PTO-PHA_ods.txt | 104 + MMT_SQL/ods/PTO-PNA-ods.txt | 176 ++ .../{BUDNI_PTO_ODS.SQL => PTO-RPT-ods.txt} | 102 +- MMT_SQL/ods/ftdry_trs_ods.sql | 178 -- MMT_SQL/onetime/create_table_DBOECD-TEST.txt | 750 +++++++ MMT_SQL/onetime/create_table_DBSTD_TEST.txt | 695 +++++++ MMT_SQL/onetime/create_tables_BUDNI_ARC.txt | 223 ++ ...ni_dbp.sql => create_tables_BUDNI_DBP.txt} | 6 +- MMT_SQL/onetime/create_tables_BUDNI_FLD.txt | 333 +++ MMT_SQL/onetime/create_tables_BUDNI_HDL.txt | 302 +++ MMT_SQL/onetime/create_tables_BUDNI_HLG.txt | 249 +++ MMT_SQL/onetime/create_tables_BUDNI_LCG.txt | 201 ++ MMT_SQL/onetime/create_tables_BUDNI_NMT.txt | 348 ++++ ...ni_pto.sql => create_tables_BUDNI_PTO.txt} | 15 +- MMT_SQL/onetime/create_tables_BUDNI_VMT.txt | 224 ++ MMT_SQL/onetime/create_tables_FTDRY_SUM.txt | 335 +++ MMT_SQL/onetime/create_tables_FTDRY_TRS.txt | 303 +++ MMT_SQL/onetime/create_tables_FTHLG_SUM.txt | 322 +++ MMT_SQL/onetime/create_tables_FTHLG_TRS.txt | 312 +++ MMT_SQL/onetime/create_tables_FTWET_SUM.txt | 302 +++ MMT_SQL/onetime/create_tables_FTWET_TRS.txt | 313 +++ MMT_SQL/onetime/create_tables_PTO.txt | 1402 +++++++++++++ MMT_SQL/onetime/create_tables_trs_sum.sql | 1847 ----------------- MMT_SQL/staging2/DBOECD-TEST-stg2.txt | 1435 +++++++++++++ MMT_SQL/staging2/DBSTD_TEST_stg2.SQL | 1332 ++++++++++++ MMT_SQL/staging2/PTO-GVG_stg2.txt | 351 ++++ MMT_SQL/staging2/PTO-MPM-stg2.txt | 168 ++ MMT_SQL/staging2/PTO-PHA-stg2.txt | 457 ++++ MMT_SQL/staging2/PTO-PNA-stg2.txt | 810 ++++++++ MMT_SQL/staging2/PTO-RPT-stg2.txt | 325 +++ MMT_SQL/staging2/budni_dbp_execute.sql | 199 -- MMT_SQL/staging2/budni_pto_execute.sql | 283 --- MMT_SQL/staging2/dry_sum_execute.sql | 397 ---- MMT_SQL/staging2/dry_trs_execute.sql | 345 --- MMT_SQL/staging2/hlg_sum_execute.sql | 403 ---- MMT_SQL/staging2/hlg_trs_execute.sql | 331 --- MMT_SQL/staging2/wet_sum_execute.sql | 289 --- MMT_SQL/staging2/wet_trs_execute.sql | 342 --- 50 files changed, 13665 insertions(+), 5835 deletions(-) create mode 100644 MMT_SQL/common/config.txt create mode 100644 MMT_SQL/common/delete-ods.txt delete mode 100644 MMT_SQL/ods/BUDNI_DBP_ODS.SQL create mode 100644 MMT_SQL/ods/DBOECD-TEST-ods.txt create mode 100644 MMT_SQL/ods/DBSTD_TEST_ODS.SQL delete mode 100644 MMT_SQL/ods/FTDRY_SUM_ODS.sql delete mode 100644 MMT_SQL/ods/FTHLG_SUM_ODS.sql delete mode 100644 MMT_SQL/ods/FTHLG_TRS_ODS.sql delete mode 100644 MMT_SQL/ods/FTWET_SUM_ODS.sql delete mode 100644 MMT_SQL/ods/FTWET_TRS_ODS.sql create mode 100644 MMT_SQL/ods/PTO-GVG_ods.txt create mode 100644 MMT_SQL/ods/PTO-MPM_ods.txt create mode 100644 MMT_SQL/ods/PTO-PHA_ods.txt create mode 100644 MMT_SQL/ods/PTO-PNA-ods.txt rename MMT_SQL/ods/{BUDNI_PTO_ODS.SQL => PTO-RPT-ods.txt} (57%) delete mode 100644 MMT_SQL/ods/ftdry_trs_ods.sql create mode 100644 MMT_SQL/onetime/create_table_DBOECD-TEST.txt create mode 100644 MMT_SQL/onetime/create_table_DBSTD_TEST.txt create mode 100644 MMT_SQL/onetime/create_tables_BUDNI_ARC.txt rename MMT_SQL/onetime/{create_tables_budni_dbp.sql => create_tables_BUDNI_DBP.txt} (97%) create mode 100644 MMT_SQL/onetime/create_tables_BUDNI_FLD.txt create mode 100644 MMT_SQL/onetime/create_tables_BUDNI_HDL.txt create mode 100644 MMT_SQL/onetime/create_tables_BUDNI_HLG.txt create mode 100644 MMT_SQL/onetime/create_tables_BUDNI_LCG.txt create mode 100644 MMT_SQL/onetime/create_tables_BUDNI_NMT.txt rename MMT_SQL/onetime/{create_tables_budni_pto.sql => create_tables_BUDNI_PTO.txt} (95%) create mode 100644 MMT_SQL/onetime/create_tables_BUDNI_VMT.txt create mode 100644 MMT_SQL/onetime/create_tables_FTDRY_SUM.txt create mode 100644 MMT_SQL/onetime/create_tables_FTDRY_TRS.txt create mode 100644 MMT_SQL/onetime/create_tables_FTHLG_SUM.txt create mode 100644 MMT_SQL/onetime/create_tables_FTHLG_TRS.txt create mode 100644 MMT_SQL/onetime/create_tables_FTWET_SUM.txt create mode 100644 MMT_SQL/onetime/create_tables_FTWET_TRS.txt create mode 100644 MMT_SQL/onetime/create_tables_PTO.txt delete mode 100644 MMT_SQL/onetime/create_tables_trs_sum.sql create mode 100644 MMT_SQL/staging2/DBOECD-TEST-stg2.txt create mode 100644 MMT_SQL/staging2/DBSTD_TEST_stg2.SQL create mode 100644 MMT_SQL/staging2/PTO-GVG_stg2.txt create mode 100644 MMT_SQL/staging2/PTO-MPM-stg2.txt create mode 100644 MMT_SQL/staging2/PTO-PHA-stg2.txt create mode 100644 MMT_SQL/staging2/PTO-PNA-stg2.txt create mode 100644 MMT_SQL/staging2/PTO-RPT-stg2.txt delete mode 100644 MMT_SQL/staging2/budni_dbp_execute.sql delete mode 100644 MMT_SQL/staging2/budni_pto_execute.sql delete mode 100644 MMT_SQL/staging2/dry_sum_execute.sql delete mode 100644 MMT_SQL/staging2/dry_trs_execute.sql delete mode 100644 MMT_SQL/staging2/hlg_sum_execute.sql delete mode 100644 MMT_SQL/staging2/hlg_trs_execute.sql delete mode 100644 MMT_SQL/staging2/wet_sum_execute.sql delete mode 100644 MMT_SQL/staging2/wet_trs_execute.sql diff --git a/MMT_SQL/common/config.txt b/MMT_SQL/common/config.txt new file mode 100644 index 0000000..948f8e0 --- /dev/null +++ b/MMT_SQL/common/config.txt @@ -0,0 +1,145 @@ +insert into mmt_ods.mmt_config +(file_format,sheet_mnemonic,rank_tag,f1_modified) +values ('DBSTD','DBSTD_TEST','DBSTD_Test_H1','Test Request no.'), +('DBSTD','DBSTD_TEST','DBSTD_test_engine_RPM','Engine (RPM)'), +('DBSTD','DBSTD_TEST','DBSTD_test_test_condition','Test condition'), +('DBSTD','DBSTD_TEST','DBSTD_test_drawbar_performance_selected_summary','Drawbar Performance Test Results (Selected Summary)'), +('DBSTD','DBSTD_TEST','DBSTD_test_drawbar_performance_gear_performance','Drawbar Performance Test Results (Gear Performance Test)'), +('DBSTD','DBSTD_TEST','DBSTD_test_test_equipment','Test equipment’s used'), +('DBSTD','DBSTD_TEST','DBSTD_test_tractor_specifications','Tractor specification'), +('DBSTD','DBSTD_TEST','DBSTD_test_transmission','Transmission'), +('DBSTD','DBSTD_TEST','DBSTD_test_graphical_data','GRAPHICAL DATA'), +('DBSTD','DBSTD_TEST','DBSTD_test_photos','PHOTOS'), +('DBSTD','DBSTD_TEST','DBSTD_test_remarks','Remarks'); + + + +insert into mmt_ods.mmt_config +(file_format,sheet_mnemonic,rank_tag,f1_modified) +values +('FTDRY','FTDRY_TRS','FTDRY_TRS_H1','Tractor Specifications Sheet'), +('FTDRY','FTDRY_TRS','FTDRY_TRS_SPEC','Tractor Specifications'), +('FTDRY','FTDRY_TRS','FTDRY_TRS_Engine_RPM','Engine RPM Data:'), +('FTDRY','FTDRY_TRS','FTDRY_TRS_Implement','Implement Details'), +('FTDRY','FTDRY_SUM','FTDRY_SUM_Trac_H1','Tractor Model'), +('FTDRY','FTDRY_SUM','FTDRY_SUM_Implement','Make of Implement'), +('FTDRY','FTDRY_SUM','FTDRY_SUM_Test_Condition_1','Test Condition_1:'), +('FTDRY','FTDRY_SUM','FTDRY_SUM_Engineer_Comments_1','Test Engineer Comments_1'), +('FTDRY','FTDRY_SUM','FTDRY_SUM_Manager_Comments_1','Test Manager Comments_1'), +('FTDRY','FTDRY_SUM','FTDRY_SUM_Test_Condition_2','Test Condition_2:'), +('FTDRY','FTDRY_SUM','FTDRY_SUM_Engineer_Comments_2','Test Engineer Comments_2'), +('FTDRY','FTDRY_SUM','FTDRY_SUM_Manager_Comments_2','Test Manager Comments_2'); + + +insert into mmt_ods.mmt_config +(file_format,sheet_mnemonic,rank_tag,f1_modified) +values +('FTWET','FTWET_TRS','FTWET_TRS_H1','Tractor Specifications Sheet'), +('FTWET','FTWET_TRS','FTWET_TRS_SPEC','Tractor Specifications'), +('FTWET','FTWET_TRS','FTWET_TRS_Engine_RPM','Engine RPM Data:'), +('FTWET','FTWET_TRS','FTWET_TRS_Implement','Implement Details'), +('FTWET','FTWET_SUM','FTWET_SUM_Trac_H1','Tractor Model'), +('FTWET','FTWET_SUM','FTWET_SUM_Impement','Make of Implement'), +('FTWET','FTWET_SUM','FTWET_SUM_Cage_Wheel','Type of Cage Wheel'), +('FTWET','FTWET_SUM','FTWET_SUM_Test_Condition','Test Condition:'), +('FTWET','FTWET_SUM','FTWET_SUM_Manager_Comment','Test Manager Comments'); + + + +insert into mmt_ods.mmt_config +(file_format,sheet_mnemonic,rank_tag,f1_modified) +values +('FTHLG','FTHLG_TRS','FTHLG_TRS_H1','Tractor specifications sheet'), +('FTHLG','FTHLG_TRS','FTHLG_TRS_SPEC','Tractor Specifications'), +('FTHLG','FTHLG_TRS','FTHLG_TRS_Engine_RPM','Engine RPM Data:'), +('FTHLG','FTHLG_TRS','FTHLG_TRS_Trailer','Trailer Details'), +('FTHLG','FTHLG_SUM','FTHLG_SUM_Trac_H1','Tractor Model'), +('FTHLG','FTHLG_SUM','FTHLG_SUM_Trail_Type','Trailer Type'), +('FTHLG','FTHLG_SUM','FTHLG_SUM_Test_Condition_1','Test Condition_1:'), +('FTHLG','FTHLG_SUM','FTHLG_SUM_Engineer_Comments_1','Test Engineer Comments_1'), +('FTHLG','FTHLG_SUM','FTHLG_SUM_Manager_Comments_1','Test Manager Comments_1'), +('FTHLG','FTHLG_SUM','FTHLG_SUM_Test_Condition_2','Test Condition_2:'), +('FTHLG','FTHLG_SUM','FTHLG_SUM_Engineer_Comments_2','Test Engineer Comments_2'), +('FTHLG','FTHLG_SUM','FTHLG_SUM_Manager_Comments_2','Test Manager Comments_2'); + + + +insert into mmt_ods.mmt_config +(file_format,sheet_mnemonic,rank_tag,f1_modified) +values ('PTOBST','PTOBST_RPT','PTOBST_RPT_test_tractor_specifiactions','Test Tractor Specifiactions'), +('PTOBST','PTOBST_RPT','PTOBST_RPT_PTO_performance_report','PTO Performance Report'), +('PTOBST','PTOBST_RPT','PTOBST_RPT_MMTKeyword1','MMTKeyword1'), +('PTOBST','PTOBST_RPT','PTOBST_RPT_MMTKeyword2','MMTKeyword2'), +('PTOBST','PTOBST_RPT','PTOBST_RPT_PTO_Performance_Test_Observations_Summary','PTO Performance Test Observations Summary'), +('PTOBST','PTOBST_PNA','PTOBST_PNA_key_perfomrance_parameters','Key Performance Parameters'), +('PTOBST','PTOBST_PNA','PTOBST_PNA_boostmode_maxpower_test','Max Power Occurring Test'), +('PTOBST','PTOBST_PNA','PTOBST_PNA_2Hrs_max_power_test','2Hrs Max Power Test'), +('PTOBST','PTOBST_PNA','PTOBST_PNA_varying_speed_test','Varying Speed Test - Full Throttle Performance'), +('PTOBST','PTOBST_PNA','PTOBST_PNA_part_load_rated_rpm,','Part load @ Rated RPM'), +('PTOBST','PTOBST_PNA','PTOBST_PNA_varying_load,','Varying load @ STD. PTO'), +('PTOBST','PTOBST_PNA','PTOBST_PNA_smoke_test','Smoke Test'), +('PTOBST','PTOBST_PHA','PTOBST_PHA_KEY_performance_parameters','KEY Performance Parameters'), +('PTOBST','PTOBST_PHA','PTOBST_PHA_2Hrs_max_power_test','2Hrs Max Power Test'), +('PTOBST','PTOBST_PHA','PTOBST_PHA_varying_speed_test','Varying Speed Test'), +('PTOBST','PTOBST_PHA','PTOBST_PHA_Engine_oil_consumption','Engine Oil Consumption'), +('PTOBST','PTOBST_MPM','PTOBST_MPM_performance_boost_natuaral','Performance - Boost Mode @ Natural Ambient'), +('PTOBST','PTOBST_GVG','PTOBST_GVG_performance_governing_trails','Governing Trails on Boost Mode'), +('PTOBST','PTOBST_GVG','PTOBST_GVG_graphs','Graphs - for Example'); + + + +insert into mmt_ods.mmt_config +(file_format,sheet_mnemonic,rank_tag,f1_modified) +values +('BUDNI','BUDNI_DBP','BUDNI_DBP_Spec_H1','Test Tractor Specifiactions'), +('BUDNI','BUDNI_DBP','BUDNI_DBP_Drawbar_Perf','Tractor Drawbar Performance Report.'), +('BUDNI','BUDNI_NMT','BUDNI_NMT_Spec_H1','Test Tractor Specifiactions'), +('BUDNI','BUDNI_NMT','BUDNI_NMT_ Noise at bystander''’s position', 'Noise at bystander''’s position: Noise Measurement Test'), +('BUDNI','BUDNI_NMT','BUDNI_NMT_ Noise at operator''’s ear level','Noise at operator''’s ear level: Noise Measurement Test'), +('BUDNI','BUDNI_NMT','BUDNI_NMT_Test_Obs_Summary','Noise Measurement Test Observations Summary'), +('BUDNI','BUDNI_LCG','BUDNI_LCG_Spec_H1','Test Tractor Specifiactions'), +('BUDNI','BUDNI_LCG','BUDNI_LCG_Gravity_Test','Location of centre of Gravity Test'), +('BUDNI','BUDNI_PTO','BUDNI_PTO_Spec_H1','Test Tractor Specifiactions'), +('BUDNI','BUDNI_PTO','BUDNI_PTO_Report','PTO Performance Report'), +('BUDNI','BUDNI_PTO','BUDNI_PTO_MMTKeyword1','MMTKeyword1'), +('BUDNI','BUDNI_PTO','BUDNI_PTO_MMTKeyword2','MMTKeyword2'), +('BUDNI','BUDNI_PTO','BUDNI_PTO_Summary','PTO Performance Test Observations Summary'), +('BUDNI','BUDNI_HDL','BUDNI_HDL_Spec_H1','Test Tractor Specifiactions'), +('BUDNI','BUDNI_HDL','BUDNI_HDL_Power_Test','A) Hydraulic power test:'), +('BUDNI','BUDNI_HDL','BUDNI_HDL_Lifting_Capacity_Test','B) Lifting Capacity Test'), +('BUDNI','BUDNI_HDL','BUDNI_HDL_Maintenance_Of_Lift_Load','C) Maintenance of lift load:'), +('BUDNI','BUDNI_HDL','BUDNI_HDL_Test_Obs_Summary','Power Lift and Hydraulic Pump Performance Test Observations Summary'), +('BUDNI','BUDNI_HLG','BUDNI_HLG_Spec_H1','Test Tractor Specifiactions'), +('BUDNI','BUDNI_HLG','BUDNI_HLG_Perf_Test','Haulage performance Test'), +('BUDNI','BUDNI_HLG','BUDNI_HLG_Test_Obs_Summary','Haulage Performance Test Observations Summary'), +('BUDNI','BUDNI_FLD','BUDNI_FLD_Spec_H1','Test Tractor Specifiactions'), +('BUDNI','BUDNI_FLD','BUDNI_FLD_Impl_Test','BRIEF SPECIFICATION OF IMPLEMENTS USED DURING FIELD TEST'), +('BUDNI','BUDNI_FLD','BUDNI_FLD_Sum_Perf_Test','SUMMARY OF FIELD PERFORMANCE TEST'), +('BUDNI','BUDNI_FLD','BUDNI_FLD_Test_Obs_Summary','Field Performance Test Observations Summary'), +('BUDNI','BUDNI_ARC','BUDNI_ARC_Spec_H1','Test Tractor Specifiactions'), +('BUDNI','BUDNI_ARC','BUDNI_ARC_Perf_Atmos_Meas_Test','Atmospheric conditions:'), +('BUDNI','BUDNI_ARC','BUDNI_ARC_Test_Obs_Summary','AIR CLEANER OIL PULL OVER TEST Observations Summary'); +('BUDNI','BUDNI_VMT','BUDNI_VMT_Spec_H1','Test Tractor Specifiactions'), +('BUDNI','BUDNI_VMT','BUDNI_VMT_Perf_Meas_Test','Machanical Vibration Measurement Test'), +('BUDNI','BUDNI_VMT','BUDNI_VMT_Test_Obs_Summary','Noise Measurement Test Observations Summary'), +('BUDNI','BUDNI_BRK','BUDNI_BRK_Spec_H1','Test Tractor Specifiactions'), +('BUDNI','BUDNI_BRK','BUDNI_BRK_Service_Barke_Test','1) Service Barke Testing'), +('BUDNI','BUDNI_BRK','BUDNI_BRK_Parking_Brake_Test','2) Parking Brake Test'), +('BUDNI','BUDNI_BRK','BUDNI_BRK_Test_Obs_Summary','Brake Performance Test Observations Summary'); + + +insert into mmt_ods.mmt_config +(file_format,sheet_mnemonic,rank_tag,f1_modified) +values ('DBOECD','DBOECD_TEST','DBOECD_Test_H1','Test Request no.'), +('DBOECD','DBOECD_TEST','DBOECD_test_engine_RPM','Engine (RPM)'), +('DBOECD','DBOECD_TEST','DBOECD_test_test_condition','Test condition'), +('DBOECD','DBOECD_TEST','DBOECD_test_drawbar_performance_selected_summary','Drawbar Performance Test Results (Selected Summary)'), +('DBOECD','DBOECD_TEST','DBOECD_test_drawbar_performance_gear_performance','Drawbar Performance Test Results (Gear Performance Test)'), +('DBOECD','DBOECD_TEST','DBOECD_test_fuel_consumption','3.3.2'), +('DBOECD','DBOECD_TEST','DBOECD_test_test_equipment','Test equipment’s used'), +('DBOECD','DBOECD_TEST','DBOECD_test_tractor_specifications','Tractor specification'), +('DBOECD','DBOECD_TEST','DBOECD_test_transmission','Transmission'), +('DBOECD','DBOECD_TEST','DBOECD_test_graphical_data','GRAPHICAL DATA'), +('DBOECD','DBOECD_TEST','DBOECD_test_photos','PHOTOS'), +('DBOECD','DBOECD_TEST','DBOECD_test_remarks','Remarks: '); + diff --git a/MMT_SQL/common/delete-ods.txt b/MMT_SQL/common/delete-ods.txt new file mode 100644 index 0000000..feb5d6a --- /dev/null +++ b/MMT_SQL/common/delete-ods.txt @@ -0,0 +1,38 @@ +update mmt_staging1.mmt_staging_generic_table +set column53=0 +where file_syspk = 263; +update mmt_staging1.mmt_staging_generic_table +set column53=0 +where file_syspk = 262; + +delete from mmt_ods.test_instance where test_file_ref_no = 263; +delete from mmt_ods.test_instance_engine_info where test_file_ref_no = 263; +delete from mmt_ods.test_instance_tractor_info where test_file_ref_no = 263; +delete from mmt_ods.test_instance_drawbar_info where test_file_ref_no = 263; +delete from mmt_ods.test_instance_tyre_info where test_file_ref_no = 263; +delete from mmt_ods.drawbar_perf_results_summary where test_file_ref_no = 263; +delete from mmt_ods.drawbar_perf_oecd_results where test_file_ref_no = 263; +delete from mmt_ods.drawbar_perf_results where test_file_ref_no = 263; +delete from mmt_ods.test_instance_equipment_info where test_file_ref_no = 263; +delete from mmt_ods.test_instance_measurement_uncertainty where test_file_ref_no = 263; +delete from mmt_ods.test_instance_tractor_info_misc where test_file_ref_no = 263; +delete from mmt_ods.test_instance_gear_speed_chart where test_file_ref_no = 263; +delete from mmt_ods.Test_instance_wheels_info where test_file_ref_no = 263; +delete from mmt_ods.Test_instance_fuel_lubricant_info where test_file_ref_no = 263; +delete from mmt_ods.drawbar_perf_observations where test_file_ref_no = 263; + + +delete from mmt_ods.test_instance where test_file_ref_no = 262; +delete from mmt_ods.test_instance_engine_info where test_file_ref_no = 262; +delete from mmt_ods.test_instance_tractor_info where test_file_ref_no = 262; +delete from mmt_ods.test_instance_drawbar_info where test_file_ref_no = 262; +delete from mmt_ods.test_instance_tyre_info where test_file_ref_no = 262; +delete from mmt_ods.drawbar_perf_results_summary where test_file_ref_no = 262; +delete from mmt_ods.drawbar_perf_results where test_file_ref_no = 262; +delete from mmt_ods.test_instance_equipment_info where test_file_ref_no = 262; +delete from mmt_ods.test_instance_measurement_uncertainty where test_file_ref_no = 262; +delete from mmt_ods.test_instance_tractor_info_misc where test_file_ref_no = 262; +delete from mmt_ods.test_instance_gear_speed_chart where test_file_ref_no = 262; +delete from mmt_ods.Test_instance_wheels_info where test_file_ref_no = 262; +delete from mmt_ods.Test_instance_fuel_lubricant_info where test_file_ref_no = 262; +delete from mmt_ods.drawbar_perf_observations where test_file_ref_no = 262; \ No newline at end of file diff --git a/MMT_SQL/ods/BUDNI_DBP_ODS.SQL b/MMT_SQL/ods/BUDNI_DBP_ODS.SQL deleted file mode 100644 index 028db30..0000000 --- a/MMT_SQL/ods/BUDNI_DBP_ODS.SQL +++ /dev/null @@ -1,125 +0,0 @@ -drop function if exists mmt_staging2.fn_BUDNI_DBP_ODS ; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_BUDNI_DBP_ODS() - RETURNS void AS $$ - begin - - insert into mmt_ods.test_instance_tractor_info - ( -client_id, -function_id, -test_file_ref_no, -test_file_format, -test_file_sheet_format, -tractor_make, -tractor_model, -configuration, -Transmission_type, - Wheel_Drive_Type, - Steering_type, - Hitch_Height, - Ballast_condition - ) - select - client_id, -function_id, -file_syspk , -file_format, -sheet_mnemonic, - column3, - column4, - column7, - column8, - column9, - column11, - column13::int, - column14 - from mmt_staging2.BUDNI_DBP_Spec_H1_Block where ods_record =1 ; - - insert into mmt_ods.test_instance - ( -client_id, -function_id, -test_file_ref_no, -test_file_format, -test_file_sheet_format, -tractor_make, -tractor_model, -type_of_road - ) - select - client_id, -function_id, -file_syspk , -file_format, -sheet_mnemonic, - column3, - column4, - column15 - from mmt_staging2.BUDNI_DBP_Spec_H1_Block where ods_record =1 ; - -insert into mmt_ods.test_instance_engine_info - ( -client_id, -function_id, -test_file_ref_no, -test_file_format, -test_file_sheet_format, -tractor_make, -tractor_model, -Rated_RPM, -engine_to_pto_ratio_540_pto - ) - select - client_id, -function_id, -file_syspk , -file_format, -sheet_mnemonic, - column3, - column4, - column6::int, - column12 - from mmt_staging2.BUDNI_DBP_Spec_H1_Block where ods_record =1 ; - - -insert into mmt_ods.budni_drawbar_perf_results -( -client_id, -function_id, -test_file_ref_no, -test_file_format, -test_file_sheet_format, -tractor_make, -tractor_model, -test_condtion, -gear_used, -travel_speed_km_per_h, -drawbar_power_kw, -drawbar_pull_kn, -engine_speed_rpm, -wheel_slip_pct, -fuel_consumption_kg_per_kwh, -fuel_consumption_l_per_h, -specific_energy_kwh_per_ltr, -atmosp_conditions_pressure_kpa, -atmosp_conditions_rh_pct, -atmosp_conditions_temp_c, -temp_trans_oil_c, -temp_coolant_c, -temp_fuel_c, -temp_engine_oil_c -) -select -client_id,function_id,file_syspk,file_format,sheet_mnemonic,make,model, -column2,column3,column4::float,column5::float,column6::float,column7::float, -column8::float,column9::float,column10::float,column11::float,column12,column13, -column14,column15,column16,column17,column18 -from mmt_staging2.BUDNI_DBP_Drawbar_Perf_Block where ods_record = 1; - -end -$$ LANGUAGE plpgsql; - -select mmt_staging2.fn_BUDNI_DBP_ODS(); - - - diff --git a/MMT_SQL/ods/DBOECD-TEST-ods.txt b/MMT_SQL/ods/DBOECD-TEST-ods.txt new file mode 100644 index 0000000..42f8ec5 --- /dev/null +++ b/MMT_SQL/ods/DBOECD-TEST-ods.txt @@ -0,0 +1,759 @@ +--select mmt_ods.fn_dboecd_test_ods(); + +drop function if exists mmt_ods.fn_dboecd_test_ods; +CREATE OR REPLACE FUNCTION mmt_ods.fn_dboecd_test_ods() + RETURNS void AS $$ + begin + +/*********************************************************** +Function Name:fn_dboecd_test_ods +Function Desc: This function populates data into ods block +File Format: DBOECD +Sheet Format: DBOECD_TEST +Creation Date: March 27 2021 +Updation Date: +Author: compegence team +Function Call: select mmt_ods.fn_dboecd_test_ods() +***************************************************************/ +SET search_path TO mmt_staging2; + +insert into mmt_ods.test_instance +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +job_order_no, +sample_receipt_date, +test_report_no, +generation, +customer_name, +test_engineer, +test_report_date, +no_of_sample, +test_start_date, +test_end_date, +tractor_sr_no, +test_standard_ref, +test_location_name, +test_operator, +project_group, +acceptance_criteria, +objective_of_test, +test_file_format, +test_file_sheet_format, +date_of_test +) +select +client_id, +function_id, +file_syspk, +make, +model, +test_request_no, +date '1899-12-30' + sample_receipt_date::int * interval '1' day as sample_receipt_date , +test_report_no, +generation, +customer_name, +test_engineer, +date '1899-12-30' + test_report_date::int * interval '1' day as test_report_date , +no_of_sample, +date '1899-12-30' + test_start_date::int* interval '1' day as test_start_date , +date '1899-12-30' + test_end_date::int* interval '1' day as test_end_date , +tractor_sr_no, +test_standard_refer, +test_location, +operator_name, +project_group, +objective, +acceptance_criteria, +file_format, +sheet_mnemonic, +current_date +from +mmt_staging2.dboecd_test_h1_block; + +update mmt_ods.test_instance a +set test_condition=b.c2 +from mmt_staging2.dboecd_test_test_condition_block b +where a.test_file_ref_no=b.file_syspk; + +update mmt_ods.test_instance a +set remarks = b.remark +from mmt_staging2.dboecd_test_drawbar_performance_fuel_consumption_block b +where a.test_file_ref_no=b.file_syspk; + +insert into mmt_ods.test_instance_engine_info +(client_id,function_id,test_file_ref_no,tractor_model,tractor_make,low_idle_declared,low_idle_observed,high_idle_declared,high_idle_observed) +select client_id,function_id,file_syspk,make,model,low_idle_declared,low_idle_observed::int,high_idle_declared,high_idle_observed::int +from mmt_staging2.DBOECD_test_engine_RPM_RPM_block; + + +update mmt_ods.test_instance_engine_info a +set rated_rpm=b.rated_speed::int ,engine_to_pto_ratio_540_pto=b.engine_to_pto_ratio::numeric::int +from +mmt_staging2.dboecd_test_engine_rpm_engine_to_pto_block b +where a.test_file_ref_no=b.file_syspk; + +update mmt_ods.test_instance_engine_info a +set engine_cylinder_stroke_mm=b.stroke::int,engine_cylinder_bore_mm=b.bore::numeric,engine_cylinder_no=b.number::int,engine_cylinder_capacity_ltr=b.capacity::int +from mmt_staging2.dboecd_test_tractor_specifications_cylinders_block b +where test_file_ref_no=b.file_syspk; + + +update mmt_ods.test_instance_engine_info a +set engine_serial_no=serial_no,engine_type=type,rated_rpm=rated_speed::int +from mmt_staging2.dboecd_test_tractor_specifications_engine_details_block b +where test_file_ref_no=b.file_syspk; + + +insert into mmt_ods.test_instance_tractor_info +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +wheel_base_mm, +tractor_engine_hp, +pto_power_hp, +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +wheel_base_mm::int, +engine_power_hp::int, +pto_power_hp::numeric, +file_format, +sheet_mnemonic +from mmt_staging2.dboecd_test_engine_rpm_engine_to_pto_block; + +update mmt_ods.test_instance_tractor_info a +set +steering_type=b.steering_type, +transmission_type=clutch_type, +transmission_disc_diam=diameter_of_disc_mm +from mmt_staging2.dboecd_test_transmission_clutch_block b +where a.test_file_ref_no=b.file_syspk; + + +insert into mmt_ods.test_instance_drawbar_info +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +drawbar_type, +required_pull_in_kg, +actual_pull_in_kg, +required_power_in_hp, +actual_power_in_hp, +calculated_hitch_height_mm, +actual_hitch_height_mm, +test_file_format, +test_file_sheet_format +) + +select +client_id, +function_id, +file_syspk, +make, +model, +pull_type, +required_pull_in_kg::numeric , +actual_pull_in_kg::numeric , +required_power_in_hp::numeric, +actual_power_in_hp::numeric , +calculated_hitch_height_mm::numeric, +actual_hitch_height_mm::numeric, +file_format, +sheet_mnemonic +from + mmt_staging2.dboecd_test_engine_rpm_required_pull_block; + +update mmt_ods.test_instance_drawbar_info a +set weight_front_kg = front::int , +weight_rear_kg = rear::int , +weight_total_kg = total::int +from mmt_staging2.dboecd_test_engine_rpm_weight_block b +where b.weight_kg='Unballast' +and a.drawbar_type='UB' +and a.test_file_ref_no=b.file_syspk; + + +update mmt_ods.test_instance_drawbar_info a +set weight_front_kg = front::int , +weight_rear_kg = rear::int , +weight_total_kg = total::int +from mmt_staging2.dboecd_test_engine_rpm_weight_block b +where b.weight_kg='Ballast' +and a.drawbar_type='B' +and a.test_file_ref_no=b.file_syspk; + +update mmt_ods.test_instance_drawbar_info a +set test_condition=b.test_condition, +drawbar_type_info=b.type, +height_above_ground_max_mm=b.height_above_ground_max_mm::numeric, +height_above_ground_min_mm=b.height_above_ground_min_mm::numeric, +position_related_to_pto=b.position_related_to_pto, +wheel_base=b.wheel_base +from mmt_staging2.dboecd_test_transmission_drawbar_block b +where a.drawbar_type=b.test_condition +and a.test_file_ref_no=b.file_syspk; + +update mmt_ods.test_instance_drawbar_info set drawbar_type_name='Un-Ballasted' where drawbar_type='UB'; +update mmt_ods.test_instance_drawbar_info set drawbar_type_name='Ballasted' where drawbar_type='B'; + +insert into mmt_ods.test_instance_tyre_info +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +tyre_type, +tyre_make, +tyre_size, +tyre_ply_rating, +tyre_load_carrying_capacity, +tyre_pressure_kg_per_cm2, +tyre_number_of_lug, +tyre_number_of_no_load_lug_30m, +tyre_lug_height, +tyre_dynamic_rolling_radius_mm, +tyre_wheel_rim_make_and_size, +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +dummy_f, +tyre_make, +size, +ply_rating::int, +load_carrying_capacity_in_kg, +pressure_kg_cm2::numeric, +number_of_lug::int, +number_of_no_load_lug_30m::int, +lug_height::numeric, +dynamic_rolling_radius_mm::numeric, +wheel_rim_make_size, +file_format, +sheet_mnemonic + from mmt_staging2.DBOECD_test_engine_RPM_tyre_details_block ; + + insert into mmt_ods.drawbar_perf_results_summary + ( + client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +gear_number_and_range, +travel_speed_km_per_hr, +drawbar_power_kw, +drawbar_power_hp, +drawbar_pull_kgf, +drawbar_pull_kn, +engine_speed_min_1, +fan_speed_min_1, +wheel_slip_pct_front, +no_of_load_lugs_front, +wheel_slip_pct_rear, +fuel_consumption_l_per_h, +fuel_consumption_kg_per_kwh, +fuel_consumption_g_per_kwh, +fuel_consumption_kwh_per_l, +temp_engine_oil_c, +temp_trans_oil_c, +temp_coolant_c, +temp_fuel_in_c, +temp_fuel_out_c, +atm_conditions_rh_pct, +atm_conditions_temp_c, +atm_conditions_pressure_kpa, +test_file_format, +test_file_sheet_format +) + select + client_id, +function_id, +file_syspk, +make, +model, + c1, + c2::numeric, +c3::numeric, +c4::numeric, +c5::int, +c6::numeric, +c7::int, +c8::int, +c9::numeric, +c10::numeric, +c11::numeric, +c12::numeric, +c13::numeric, +c14::numeric, +c15::numeric, +c16::int, +c17::int, +c18::int, +c19::int, +c20::int, +c21::numeric, +c22::numeric, +c23::numeric, +file_format, +sheet_mnemonic + from mmt_staging2.dboecd_test_drawbar_performance_selected_summary_block; + +insert into mmt_ods.drawbar_perf_oecd_results + ( + client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +srl_no, +test_condition , +gear_number_and_range, +travel_speed_km_per_hr, +drawbar_power_kw, +drawbar_power_hp, +drawbar_pull_kgf, +drawbar_pull_kn, +engine_speed_min_1, +fan_speed_min_1, +wheel_slip_pct_front, +no_of_load_lugs_front, +wheel_slip_pct_rear, +fuel_consumption_l_per_h, +fuel_consumption_kg_per_kwh, +fuel_consumption_g_per_kwh, +fuel_consumption_kwh_per_l, +temp_engine_oil_c, +temp_trans_oil_c, +temp_coolant_c, +temp_fuel_in_c, +temp_fuel_out_c, +atm_conditions_rh_pct, +atm_conditions_temp_c, +atm_conditions_pressure_kpa, +test_file_format, +test_file_sheet_format +) + select + client_id, +function_id, +file_syspk, +make, +model, +c1_1, + c2_1, + c1, + c2::numeric, +c3::numeric, +c4::numeric, +c5::int, +c6::numeric, +c7::int, +c8::int, +c9::numeric, +c10::numeric, +c11::numeric, +c12::numeric, +c13::numeric, +c14::numeric, +c15::numeric, +c16::int, +c17::int, +c18::int, +c19::int, +c20::int, +c21::numeric, +c22::numeric, +c23::numeric, +file_format, +sheet_mnemonic +from mmt_staging2.dboecd_test_drawbar_performance_fuel_consumption_block; + + +insert into mmt_ods.drawbar_perf_results + ( client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +gear_number_and_range, +travel_speed_km_per_hr, +drawbar_power_kw, +drawbar_power_hp, +drawbar_pull_kgf, +drawbar_pull_kn, +engine_speed_min_1, +fan_speed_min_1, +wheel_slip_pct_front, +no_of_load_lugs_front, +wheel_slip_pct_rear, +fuel_consumption_l_per_h, +fuel_consumption_kg_per_kwh, +fuel_consumption_g_per_kwh, +fuel_consumption_kwh_per_l, +temp_engine_oil_c, +temp_trans_oil_c, +temp_coolant_c, +temp_fuel_in_c, +temp_fuel_out_c, +atm_conditions_rh_pct, +atm_conditions_temp_c, +atm_conditions_pressure_kpa, +test_file_format, +test_file_sheet_format +) + select + client_id, +function_id, +file_syspk, +make, +model, + c1, + c2::numeric, +c3::numeric, +c4::numeric, +c5::int, +c6::numeric, +c7::int, +c8::int, +c9::numeric, +c10::numeric, +c11::numeric, +c12::numeric, +c13::numeric, +c14::numeric, +c15::numeric, +c16::int, +c17::int, +c18::int, +c19::int, +c20::int, +c21::numeric, +c22::numeric, +c23::numeric, +file_format, +sheet_mnemonic + from mmt_staging2.dboecd_test_drawbar_performance_gear_performance_block; + + + insert into mmt_ods.test_instance_equipment_info + (client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +srl_no, +instrument_name, +instrument_serial_no, +calibration_due_date, +test_file_format, +test_file_sheet_format ) +select + client_id, +function_id, +file_syspk, +make, +model, + s_no::int, + instruments, + instruments_no, + date '1899-12-30' + cali_due_date::int * interval '1' day as cali_due_date, + file_format, +sheet_mnemonic + from mmt_staging2.DBOECD_test_test_equipment_used_block; + +insert into mmt_ods.test_instance_measurement_uncertainty +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +load_cell, +rpm_meter, +speed, +fuel_flow_meter, +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +load_cell, +rpm_meter, +speed, +fuel_flow_meter, +file_format, +sheet_mnemonic +from +mmt_staging2.dboecd_test_measurement_uncertainty_block; + +insert into mmt_ods.test_instance_tractor_info_misc +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +capacity_of_fuel_tank_ltr, +make_type_and_model_of_injection_pump, +manufacturers_production_setting, +make_type_and_model_of_injectors, +make_type_and_model_of_magneto_coil_and_distributor, +make_type_and_model_of_carburetor, +ignition_or_injection_timing, +test_file_format, +test_file_sheet_format +) +select + client_id, +function_id, +file_syspk, +make, +model, +regexp_replace(capacity_of_fuel_tank_lit,'[^0-9]', '', 'g')::int, +make_type_and_model_of_injection_pump, +manufacturer_production_setting, +make_type_and_model_of_injectors, +make_type_and_model_of_magneto_coil_and_distributor, +make_type_and_model_of_carburetor, +ignition_or_injection_timing_manual_or_automatic, +file_format, +sheet_mnemonic +from +mmt_staging2.dboecd_test_tractor_specifications_fuel_and_injection_block; + + +update mmt_ods.test_instance_tractor_info_misc a +set aircleaner_make_model=b.make_and_model +from mmt_staging2.dboecd_test_tractor_specifications_cleaner_block b +where b.cleaner_type='Air cleaner' +and a.test_file_ref_no=b.file_syspk; + + +update mmt_ods.test_instance_tractor_info_misc a +set aircleaner_type=b.type +from mmt_staging2.dboecd_test_tractor_specifications_cleaner_block b +where cleaner_type='Air cleaner' +and a.test_file_ref_no=b.file_syspk; + + +update mmt_ods.test_instance_tractor_info_misc a +set precleaner_make_model=b.make_and_model +from mmt_staging2.dboecd_test_tractor_specifications_cleaner_block b +where cleaner_type='Precleaner (if fitted)' +and a.test_file_ref_no=b.file_syspk; + +update mmt_ods.test_instance_tractor_info_misc a +set precleaner_type=b.type +from mmt_staging2.dboecd_test_tractor_specifications_cleaner_block b +where cleaner_type='Precleaner (if fitted)' +and a.test_file_ref_no=b.file_syspk; + + +update mmt_staging2.dboecd_test_transmission_speed_chart_block a +set tyre_condition=b.descr +from mmt_staging2.dboecd_test_transmission_speed_chart_desc_block b +where a.file_syspk=b.file_syspk; + + +insert into mmt_ods.test_instance_gear_speed_chart +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +forward_reverse, +gear, +speed_kmph, +tyre_condition, +test_file_format, +test_file_sheet_format +) +select + client_id, +function_id, +file_syspk, +make, +model, + 'forward', + gear, + cast(coalesce(nullif(forward,''),'0') as numeric), + tyre_condition, + file_format, +sheet_mnemonic + from + mmt_staging2.dboecd_test_transmission_speed_chart_block; + + + insert into mmt_ods.test_instance_gear_speed_chart +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +forward_reverse, +gear, +speed_kmph, +tyre_condition, +test_file_format, +test_file_sheet_format +) +select + client_id, +function_id, +file_syspk, +make, +model, + 'reverse', + gear, + cast(coalesce(nullif(reverse,''),'0') as numeric), + tyre_condition, + file_format, +sheet_mnemonic + from + mmt_staging2.dboecd_test_transmission_speed_chart_block; + + + +insert into mmt_ods.Test_instance_wheels_info +(client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +steered_driving_wheel, +location_of_driving_wheel, +make_of_tyres, +wheel_types, +wheel_size, +maximum_permissible_load_kg, +ply_rating, +track_width_max_mm, +track_width_min_mm, +inflation_pressure_kg_per_cm2, +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +dummy_f, +location_of_driving_wheel, +make_of_tyres, +types, +size, +maximum_permissible_load_kg::int, +ply_rating::int, +track_width_max_mm::int, +track_width_min_mm::int, +inflation_pressure_kg_cm2::numeric, +file_format, +sheet_mnemonic +from mmt_staging2.dboecd_test_transmission_wheels_block; + + +insert into mmt_ods.Test_instance_fuel_lubricant_info +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +trade_name, +fuel_lubricant_type, +octane_per_cetane_number, +viscocity, +density_at_15c, +test_file_format, +test_file_sheet_format +) +select + client_id, +function_id, +file_syspk, +make, +model, + trade_name, + type, + octane_cetane_number::numeric, + viscosity, +density_at_15c, +file_format, +sheet_mnemonic +from + mmt_staging2.dboecd_test_transmission_fuel_lubricant_block ; + + +insert into mmt_ods.drawbar_perf_observations +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +test_parameter , +acceptance_criteria , +observation , +remarks, +test_file_format, +test_file_sheet_format +) +select + client_id, +function_id, +file_syspk, +make, +model, + parameter, + acceptance_criteria , + observations, + remarks, + file_format, +sheet_mnemonic +from mmt_staging2.dboecd_test_remarks_block; + +update mmt_ods.test_instance a +set +report_prepared_by=b.prepared_by, +report_reviewed_by=b.reviewed_by, +report_approved_by=b.approved_by, +report_template_replaces=b.replaces, +report_template_rev_no=b.revision_no, +report_template_rev_Date=b.rev3, +report_template_no=b.rev1, +report_title=b.comments +from mmt_staging2.dboecd_test_remarks_footer_block b +where a.test_file_ref_no=b.file_syspk; + +end +$$ LANGUAGE plpgsql; diff --git a/MMT_SQL/ods/DBSTD_TEST_ODS.SQL b/MMT_SQL/ods/DBSTD_TEST_ODS.SQL new file mode 100644 index 0000000..673ad23 --- /dev/null +++ b/MMT_SQL/ods/DBSTD_TEST_ODS.SQL @@ -0,0 +1,688 @@ +drop function if exists mmt_ods.fn_dbstd_test_ods; +CREATE OR REPLACE FUNCTION mmt_ods.fn_dbstd_test_ods() + RETURNS void AS $$ + begin + +/************************************************************ +Function Name:fn_dbstd_test_ods +Function Desc: This function populates data into ODS +File Format: DBSTD +Sheet Format: DBSTD_TEST +Creation Date: March 25 2021 +Updation Date: +Author: compegence team +Function Call: select mmt_staging2.fn_dbstd_test_ods() +***************************************************************/ + + +SET search_path TO mmt_staging2; + +/* ODS */ +insert into mmt_ods.test_instance +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +job_order_no, +sample_receipt_date, +test_report_no, +generation, +customer_name, +test_engineer, +test_report_date, +no_of_sample, +test_start_date, +test_end_date, +tractor_sr_no, +test_standard_ref, +test_location_name, +test_operator, +project_group, +acceptance_criteria, +objective_of_test, +date_of_test, +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +test_request_no, +date '1899-12-30' + sample_receipt_date::int * interval '1' day as sample_receipt_date , +test_report_no, +generation, +customer_name, +test_engineer, +date '1899-12-30' + test_report_date::int * interval '1' day as test_report_date , +no_of_sample, +date '1899-12-30' + test_start_date::int* interval '1' day as test_start_date , +date '1899-12-30' + test_end_date::int* interval '1' day as test_end_date , +tractor_sr_no, +test_standard_refer, +test_location, +operator_name, +project_group, +objective, +acceptance_criteria, +current_date, +file_format, +sheet_mnemonic +from +mmt_staging2.dbstd_test_h1_block; + +update mmt_ods.test_instance a +set test_condition=b.c2 +from mmt_staging2.dbstd_test_test_condition_block b +where a.test_file_ref_no=b.file_syspk; + +/* ODS */ +insert into mmt_ods.test_instance_engine_info +(client_id,function_id,test_file_ref_no,tractor_model,tractor_make,low_idle_declared,low_idle_observed,high_idle_declared,high_idle_observed,test_file_format, +test_file_sheet_format) +select client_id,function_id,file_syspk,make,model,low_idle_declared,low_idle_observed::int,high_idle_declared,high_idle_observed::int,file_format,sheet_mnemonic +from mmt_staging2.DBSTD_test_engine_RPM_RPM_block; + + +update mmt_ods.test_instance_engine_info a +set engine_to_pto_ratio_540_pto=b.engine_to_pto_ratio::numeric::int,engine_power_hp = b.engine_power_hp::int, +pto_power_hp = b.pto_power_hp::numeric +from +mmt_staging2.dbstd_test_engine_rpm_engine_to_pto_block b +where a.test_file_ref_no=b.file_syspk; + +update mmt_ods.test_instance_engine_info a +set engine_cylinder_stroke_mm=b.stroke::int,engine_cylinder_bore_mm=b.bore::numeric,engine_cylinder_no=b.number::int,engine_cylinder_capacity_ltr=b.capacity::int +from mmt_staging2.dbstd_test_tractor_specifications_cylinders_block b +where test_file_ref_no=b.file_syspk; + +update mmt_ods.test_instance_engine_info a +set engine_serial_no=serial_no,engine_type=type,rated_rpm=rated_speed::int,engine_make=b.make_in_block ,engine_model = b.model_in_block +from mmt_staging2.dbstd_test_tractor_specifications_engine_details_block b +where test_file_ref_no=b.file_syspk; + +/*ODS */ +insert into mmt_ods.test_instance_tractor_info +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +wheel_base_mm, +tractor_engine_hp, +pto_power_hp, +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +wheel_base_mm::int, +engine_power_hp::int, +pto_power_hp::numeric, +file_format, +sheet_mnemonic +from dbstd_test_engine_rpm_engine_to_pto_block; + +update mmt_ods.test_instance_tractor_info a +set +steering_type=b.steering_type, +transmission_type=clutch_type, +transmission_disc_diam=diameter_of_disc_mm +from mmt_staging2.dbstd_test_transmission_clutch_block b +where a.test_file_ref_no=b.file_syspk; + +/*ODS */ +insert into mmt_ods.test_instance_drawbar_info +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +drawbar_type, +required_pull_in_kg, +actual_pull_in_kg, +required_power_in_hp, +actual_power_in_hp, +calculated_hitch_height_mm, +actual_hitch_height_mm, +test_file_format, +test_file_sheet_format +) + +select +client_id, +function_id, +file_syspk, +make, +model, +pull_type, +required_pull_in_kg::numeric , +actual_pull_in_kg::numeric , +required_power_in_hp::numeric, +actual_power_in_hp::numeric , +calculated_hitch_height_mm::numeric, +actual_hitch_height_mm::numeric , +file_format, +sheet_mnemonic +from + mmt_staging2.dbstd_test_engine_rpm_required_pull_block; + +update mmt_ods.test_instance_drawbar_info a +set weight_front_kg = front::int , +weight_rear_kg = rear::int , +weight_total_kg = total::int +from mmt_staging2.dbstd_test_engine_rpm_weight_block b +where b.weight_kg='Unballast' +and a.drawbar_type='UB' +and a.test_file_ref_no=b.file_syspk; + + +update mmt_ods.test_instance_drawbar_info a +set weight_front_kg = front::int , +weight_rear_kg = rear::int , +weight_total_kg = total::int +from mmt_staging2.dbstd_test_engine_rpm_weight_block b +where b.weight_kg='Ballast' +and a.drawbar_type='B' +and a.test_file_ref_no=b.file_syspk; + +update mmt_ods.test_instance_drawbar_info a +set test_condition=b.test_condition, +drawbar_type_info=b.type, +height_above_ground_max_mm=b.height_above_ground_max_mm::numeric, +height_above_ground_min_mm=b.height_above_ground_min_mm::numeric, +position_related_to_pto=b.position_related_to_pto, +wheel_base=b.wheel_base +from mmt_staging2.dbstd_test_transmission_drawbar_block b +where a.drawbar_type=b.test_condition +and a.test_file_ref_no=b.file_syspk; + +update mmt_ods.test_instance_drawbar_info set drawbar_type_name='UnBallasted' where drawbar_type='UB'; +update mmt_ods.test_instance_drawbar_info set drawbar_type_name='Ballasted' where drawbar_type='B'; + +/* ODS */ +insert into mmt_ods.test_instance_tyre_info +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +tyre_type, +tyre_make, +tyre_size, +tyre_ply_rating, +tyre_load_carrying_capacity, +tyre_pressure_kg_per_cm2, +tyre_number_of_lug, +tyre_number_of_no_load_lug_30m, +tyre_lug_height, +tyre_dynamic_rolling_radius_mm, +tyre_wheel_rim_make_and_size, +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +dummy_f, +tyre_make, +size, +ply_rating::int, +load_carrying_capacity_in_kg, +pressure_kg_cm2::numeric, +number_of_lug::int, +number_of_no_load_lug_30m::int, +lug_height::numeric, +dynamic_rolling_radius_mm::numeric, +wheel_rim_make_size , +file_format, +sheet_mnemonic +from mmt_staging2.DBSTD_test_engine_RPM_tyre_details_block ; + +/* ODS */ + +insert into mmt_ods.drawbar_perf_results_summary + ( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +gear_number_and_range, +travel_speed_km_per_hr, +drawbar_power_kw, +drawbar_power_hp, +drawbar_pull_kgf, +drawbar_pull_kn, +engine_speed_min_1, +fan_speed_min_1, +wheel_slip_pct_front, +no_of_load_lugs_front, +wheel_slip_pct_rear, +fuel_consumption_l_per_h, +fuel_consumption_kg_per_kwh, +fuel_consumption_g_per_kwh, +fuel_consumption_kwh_per_l, +temp_engine_oil_c, +temp_trans_oil_c, +temp_coolant_c, +temp_fuel_in_c, +temp_fuel_out_c, +atm_conditions_rh_pct, +atm_conditions_temp_c, +atm_conditions_pressure_kpa, +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +c1, +c2::numeric, +c3::numeric, +c4::numeric, +c5::int, +c6::numeric, +c7::int, +c8::int, +c9::numeric, +c10::numeric, +c11::numeric, +c12::numeric, +c13::numeric, +c14::numeric, +c15::numeric, +c16::int, +c17::int, +c18::int, +c19::int, +c20::int, +c21::numeric, +c22::numeric, +c23::numeric, +file_format, +sheet_mnemonic +from mmt_staging2.dbstd_test_drawbar_performance_selected_summary_block; + +/* ODS */ +insert into mmt_ods.drawbar_perf_results +(client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +gear_number_and_range, +travel_speed_km_per_hr, +drawbar_power_kw, +drawbar_power_hp, +drawbar_pull_kgf, +drawbar_pull_kn, +engine_speed_min_1, +fan_speed_min_1, +wheel_slip_pct_front, +no_of_load_lugs_front, +wheel_slip_pct_rear, +fuel_consumption_l_per_h, +fuel_consumption_kg_per_kwh, +fuel_consumption_g_per_kwh, +fuel_consumption_kwh_per_l, +temp_engine_oil_c, +temp_trans_oil_c, +temp_coolant_c, +temp_fuel_in_c, +temp_fuel_out_c, +atm_conditions_rh_pct, +atm_conditions_temp_c, +atm_conditions_pressure_kpa, +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +c1, +c2::numeric, +c3::numeric, +c4::numeric, +c5::int, +c6::numeric, +c7::int, +c8::int, +c9::numeric, +c10::numeric, +c11::numeric, +c12::numeric, +c13::numeric, +c14::numeric, +c15::numeric, +c16::int, +c17::int, +c18::int, +c19::int, +c20::int, +c21::numeric, +c22::numeric, +c23::numeric, +file_format, +sheet_mnemonic +from mmt_staging2.dbstd_test_drawbar_performance_gear_performance_block; + +/* ODS */ +insert into mmt_ods.test_instance_equipment_info +(client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +srl_no,instrument_name,instrument_serial_no,calibration_due_date,test_file_format, +test_file_sheet_format) +select +client_id, +function_id, +file_syspk, +make, +model, +s_no::int, +instruments, +instruments_no, +date '1899-12-30' + cali_due_date::int * interval '1' day as cali_due_date , +file_format, +sheet_mnemonic +from mmt_staging2.DBSTD_test_test_equipment_used_block; + +/* ODS */ +insert into mmt_ods.test_instance_measurement_uncertainty +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +load_cell, +rpm_meter, +speed, +fuel_flow_meter, +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +load_cell, +rpm_meter, +speed, +fuel_flow_meter , +file_format, +sheet_mnemonic +from +mmt_staging2.dbstd_test_measurement_uncertainty_block; + +/* ODS */ +insert into mmt_ods.test_instance_tractor_info_misc +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +capacity_of_fuel_tank_ltr, +make_type_and_model_of_injection_pump, +manufacturers_production_setting, +make_type_and_model_of_injectors, +make_type_and_model_of_magneto_coil_and_distributor, +make_type_and_model_of_carburetor, +ignition_or_injection_timing, +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +regexp_replace(capacity_of_fuel_tank_lit,'[^0-9]', '', 'g')::int, +make_type_and_model_of_injection_pump, +manufacturer_production_setting, +make_type_and_model_of_injectors, +make_type_and_model_of_magneto_coil_and_distributor, +make_type_and_model_of_carburetor, +ignition_or_injection_timing_manual_or_automatic, +file_format, +sheet_mnemonic +from +mmt_staging2.dbstd_test_tractor_specifications_fuel_and_injection_block; + + +update mmt_ods.test_instance_tractor_info_misc a +set aircleaner_make_model=b.make_and_model +from mmt_staging2.dbstd_test_tractor_specifications_cleaner_block b +where b.cleaner_type='Air cleaner' +and a.test_file_ref_no=b.file_syspk; + + +update mmt_ods.test_instance_tractor_info_misc a +set aircleaner_type=b.type +from mmt_staging2.dbstd_test_tractor_specifications_cleaner_block b +where cleaner_type='Air cleaner' +and a.test_file_ref_no=b.file_syspk; + + +update mmt_ods.test_instance_tractor_info_misc a +set precleaner_make_model=b.make_and_model +from mmt_staging2.dbstd_test_tractor_specifications_cleaner_block b +where cleaner_type='Precleaner (if fitted)' +and a.test_file_ref_no=b.file_syspk; + +update mmt_ods.test_instance_tractor_info_misc a +set precleaner_type=b.type +from mmt_staging2.dbstd_test_tractor_specifications_cleaner_block b +where cleaner_type='Precleaner (if fitted)' +and a.test_file_ref_no=b.file_syspk; + + +update mmt_staging2.dbstd_test_transmission_speed_chart_block a +set tyre_condition=b.descr +from mmt_staging2.dbstd_test_transmission_speed_chart_desc_block b +where a.file_syspk=b.file_syspk; + +/* ODS */ + +insert into mmt_ods.test_instance_gear_speed_chart +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +forward_reverse, +gear, +speed_kmph, +tyre_condition, +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +'forward', +gear, +cast(coalesce(nullif(forward,''),'0') as numeric), +tyre_condition, +file_format, +sheet_mnemonic +from +mmt_staging2.dbstd_test_transmission_speed_chart_block; + +/* ODs */ +insert into mmt_ods.test_instance_gear_speed_chart +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +forward_reverse, +gear, +speed_kmph, +tyre_condition, +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +'reverse', +gear, +cast(coalesce(nullif(reverse,''),'0') as numeric), +tyre_condition, +file_format, +sheet_mnemonic +from +mmt_staging2.dbstd_test_transmission_speed_chart_block; + +/* ODS */ +insert into mmt_ods.Test_instance_wheels_info +(client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +steered_driving_wheel, +location_of_driving_wheel, +make_of_tyres, +wheel_types, +wheel_size, +maximum_permissible_load_kg, +ply_rating, +track_width_max_mm, +track_width_min_mm, +inflation_pressure_kg_per_cm2, +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +dummy_f, +location_of_driving_wheel, +make_of_tyres, +types, +size, +maximum_permissible_load_kg::int, +ply_rating::int, +track_width_max_mm::int, +track_width_min_mm::int, +inflation_pressure_kg_cm2::numeric, + file_format, +sheet_mnemonic +from mmt_staging2.dbstd_test_transmission_wheels_block; + +/* ODS */ +insert into mmt_ods.Test_instance_fuel_lubricant_info +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +trade_name, +fuel_lubricant_type, +octane_per_cetane_number, +viscocity, +density_at_15c, +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +trade_name, +type, +octane_cetane_number::numeric, +viscosity, +density_at_15c, +file_format, +sheet_mnemonic +from +mmt_staging2.dbstd_test_transmission_fuel_lubricant_block ; + +/* ODS */ +insert into mmt_ods.drawbar_perf_observations +( +client_id, +function_id, +test_file_ref_no, +tractor_make, +tractor_model, +test_parameter , +acceptance_criteria , +observation , +remarks , +test_file_format, +test_file_sheet_format +) +select +client_id, +function_id, +file_syspk, +make, +model, +parameter, +acceptance_criteria , +observations, +remarks , +file_format, +sheet_mnemonic +from mmt_staging2.dbstd_test_remarks_block; + +update mmt_ods.test_instance a +set +report_prepared_by=b.prepared_by, +report_reviewed_by=b.reviewed_by, +report_approved_by=b.approved_by, +report_template_replaces=b.replaces, +report_template_rev_no=b.revision_no, +report_template_rev_Date=b.rev3, +report_template_no=b.rev1, +report_title=b.comments +from mmt_staging2.dbstd_test_remarks_footer_block b +where a.test_file_ref_no=b.file_syspk; + +end +$$ LANGUAGE plpgsql; diff --git a/MMT_SQL/ods/FTDRY_SUM_ODS.sql b/MMT_SQL/ods/FTDRY_SUM_ODS.sql deleted file mode 100644 index 16c50da..0000000 --- a/MMT_SQL/ods/FTDRY_SUM_ODS.sql +++ /dev/null @@ -1,241 +0,0 @@ -drop function if exists mmt_staging2.fn_FTDRY_SUM_ODS ; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTDRY_SUM_ODS() - RETURNS void AS $$ - begin - -execute 'insert into mmt_ods.field_perf_summary_tractor_info -( -client_id, -function_id, -tractor_model, -tractor_make, -tractor_engine_hp, -rated_rpm, -transmission_type, -wheel_drive_type, -fip_type, -steering_type, -tractor_weight_front_kg, -tractor_weight_rear_kg, -tractor_weight_total_kg, -test_file_ref_no, -) -select -client_id, -function_id, -tractor_model, -tractor_make, -tractor_engine_hp::float, -rated_rpm::int, -transmission_type, -wheel_drive_type, -fip_type, -steering_type, -tractor_weight_kg_front::int, -tractor_weight_kg_rear::int, -tractor_weight_kg_total::int, -file_number -from mmt_staging2.ftdry_sum_trac_h1_block where tractor_model<> '0''; - - - -execute 'insert into mmt_ods.field_perf_summary_implement_info -( -client_id, -function_id, -make_of_implement, -implement_type, -implement_size, -hitch_category, -implement_weight, -soil_type, -soil_moisture_content_pct, -soil_bulk_density_g_per_cc, -soil_cone_index, -field_condition, -season, -test_file_ref_no -) -select -client_id, -function_id, -make_of_implement, -implement_type, -implement_size, -hitch_category, -implement_weight::int, -soil_type, -moisture_content::int soil_moisture_content_pct, -bulk_density_g_cc::int soil_bulk_density_g_per_cc, -soil_cone_index::int soil_cone_index, -field_condition, -season, -file_number -from mmt_staging2.ftdry_sum_implement_block'; - - -execute 'insert into mmt_ods.field_perf_summary -( -client_id, -function_id, -test_condition, -test_date, -tractor_model, -engine_rpm_set, -pto_rpm_set, -gear_used, -nominal_speed_kmph, -engine_rpm_drop_on_straight_1st_pass, -engine_rpm_drop_on_turn_1st_pass, -depth_of_cut_cm, -no_load_speed_kmph, -on_load_speed_kmph, -wheel_slippage_pct, -fuel_consumption_lit_per_hr, -area_covered_acr_per_hr, -fuel_consumption_lit_per_acr, -fuel_consumption_var_lit_per_hr, -area_covered_var_acr_per_hr, -fuel_consumption_var_lit_per_acr, -engine_smoke_on_load, -engine_acceleration_smoke, -draft_response, -tractor_steer_ability, -tractor_braking_perfprmance, -front_visibility, -implement_accessibility, -front_wheel_dragging_at_turning, -front_end_lifting_during_operation, -rpm_recovery_time, -engine_vibration, -engine_sound, -implement_lifting_per_lowering_response, -pulverization_index, -pulverization_quality, -test_file_ref_no -) -select -client_id, -function_id, -test_condition, -test_date::date, -tractor_model, -engine_rpm_set::int, -pto_rpm_set::int, -gear_used, -nominal_speed_kmph::float, -engine_rpm_drop_on_straight engine_rpm_drop_on_straight_1st_pass , -engine_rpm_drop_on_turn engine_rpm_drop_on_turn_1st_pass, -depth_of_cut_cm, -no_load_speed_kmph::int, -on_load_speed_kmph::int, -wheel_slippage_::int wheel_slippage_pct, -fuel_consumption_lit_hr::float fuel_consumption_lit_per_hr, -area_covered_acr_hr::int area_covered_acr_per_hr, -fuel_consumption_lit_acr::float fuel_consumption_lit_per_acr , -fuel_consumption_lit_hr_2::int fuel_consumption_var_lit_per_hr, -area_covered_acr_hr_2::int area_covered_var_acr_per_hr , -fuel_consumption_lit_acr_2::int fuel_consumption_var_lit_per_acr, -engine_smoke_on_load, -engine_acceleration_smoke , -draft_response, -tractor_steer_ability, -tractor_braking_performance, -front_visibility, -implement_accessibility, -front_wheel_dragging_at_turning, -front_end_lifting_during_operation, -rpm_recovery_time, -engine_vibration, -engine_sound, -implement_lifting_lowering_response implement_lifting_per_lowering_response, -pulverization_index, -pulverization_quality, -file_number -from mmt_staging2.ftdry_sum_test_condition_1_block where engine_rpm_set <> '0''; - -execute 'insert into mmt_ods.field_perf_summary -( -client_id, -function_id, -test_condition, -test_date, -tractor_model, -engine_rpm_set, -pto_rpm_set, -gear_used, -nominal_speed_kmph, -engine_rpm_drop_on_straight_1st_pass, -engine_rpm_drop_on_turn_1st_pass, -depth_of_cut_cm, -no_load_speed_kmph, -on_load_speed_kmph, -wheel_slippage_pct, -fuel_consumption_lit_per_hr, -area_covered_acr_per_hr, -fuel_consumption_lit_per_acr, -fuel_consumption_var_lit_per_hr, -area_covered_var_acr_per_hr, -fuel_consumption_var_lit_per_acr, -engine_smoke_on_load, -engine_acceleration_smoke, -draft_response, -tractor_steer_ability, -tractor_braking_perfprmance, -front_visibility, -implement_accessibility, -front_wheel_dragging_at_turning, -front_end_lifting_during_operation, -rpm_recovery_time, -engine_vibration, -engine_sound, -implement_lifting_per_lowering_response, -pulverization_index, -pulverization_quality, -test_file_ref_no -) -select -client_id, -function_id, -test_condition, -test_date::date, -tractor_model, -engine_rpm_set::int, -pto_rpm_set::int, -gear_used, -nominal_speed_kmph::float, -engine_rpm_drop_on_straight engine_rpm_drop_on_straight_1st_pass , -engine_rpm_drop_on_turn engine_rpm_drop_on_turn_1st_pass, -depth_of_cut_cm, -no_load_speed_kmph::int, -on_load_speed_kmph::int, -wheel_slippage_::int wheel_slippage_pct, -fuel_consumption_lit_hr::float fuel_consumption_lit_per_hr, -area_covered_acr_hr::int area_covered_acr_per_hr, -fuel_consumption_lit_acr::float fuel_consumption_lit_per_acr , -fuel_consumption_lit_hr_2::int fuel_consumption_var_lit_per_hr, -area_covered_acr_hr_2::int area_covered_var_acr_per_hr , -fuel_consumption_lit_acr_2::int fuel_consumption_var_lit_per_acr, -engine_smoke_on_load, -engine_acceleration_smoke , -draft_response, -tractor_steer_ability, -tractor_braking_performance, -front_visibility, -implement_accessibility, -front_wheel_dragging_at_turning, -front_end_lifting_during_operation, -rpm_recovery_time, -engine_vibration, -engine_sound, -implement_lifting_lowering_response implement_lifting_per_lowering_response, -pulverization_index, -pulverization_quality -file_number, -from mmt_staging2.ftdry_sum_test_condition_2_block where engine_rpm_set <> '0''; - -end -$$ LANGUAGE plpgsql; - -select mmt_staging2.fn_FTDRY_SUM_ODS(); - diff --git a/MMT_SQL/ods/FTHLG_SUM_ODS.sql b/MMT_SQL/ods/FTHLG_SUM_ODS.sql deleted file mode 100644 index 29817d3..0000000 --- a/MMT_SQL/ods/FTHLG_SUM_ODS.sql +++ /dev/null @@ -1,229 +0,0 @@ -drop function if exists mmt_staging2.fn_FTHLG_SUM_ODS ; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTHLG_SUM_ODS() - RETURNS void AS $$ - begin - - -execute 'insert into mmt_ods.field_perf_summary_tractor_info -( -client_id, -function_id, -tractor_model, -tractor_make, -tractor_engine_hp, -rated_rpm, -transmission_type, -wheel_drive_type, -fip_type, -steering_type, -tractor_weight_front_kg, -tractor_weight_rear_kg, -tractor_weight_total_kg, -test_file_ref_no -) -select -client_id, -function_id, -tractor_model, -tractor_make , -tractor_engine_hp::int, -rated_rpm::int, -transmission_type, -wheel_drive_type, -fip_type, -steering_type, -tractor_weight_kg_front::int tractor_weight_front_kg, -tractor_weight_kg_rear::int tractor_weight_rear_kg, -tractor_weight_kg_total::int tractor_weight_total_kg, -file_number -from mmt_staging2.fthlg_sum_trac_h1_block where tractor_model<> '0''; - -execute 'insert into mmt_ods.field_perf_summary_trailer_info -( -client_id, -function_id, -trailer_type, -tire_size_and_inflation_pressure_psi, -no_of_axle, -no_of_wheels, -trailer_gross_weight_kg, -tractor_rwc_to_hitch_point_center_dist_mm, -tractor_hitch_height_from_ground_mm, -trailer_hitch_height_above_ground_level_mm, -gradient_slope_1_degree, -gradient_slope_2_degree, -tractor_hitch_type, -test_file_ref_no -) -select -client_id, -function_id, -Trailer_Type, -Tire_size_and_inflation_pressure_psi, -No_Of_Axle::int , -No_Of_Wheels::int, -Trailer_Gross_Weight_Kg::int, -Tractor_Rear_Wheel_Center_to_Hitch_Point_Center_Distance_mm::int, -Tractor_Hitch_Height_from_Ground_mm::int, -Trailer_hitch_Height_above_ground_level_mm::int, -Gradient_Slope_1_Degree::int, -Gradient_Slope_2_degree::int, -Tractor_Hitch_Type, -file_number -from mmt_staging2.FTHLG_SUM_Trail_Type_Block'; - -execute 'insert into mmt_ods.field_perf_summary -( -client_id, -function_id, -test_condition, -test_date, -tractor_model, -fuel_consumption_lit_per_hr, -mileage_km_per_ltr, -avg_speed_of_travel_kmph, -total_dist_travelled_km, -gear_used_on_straight_road, -straight_road_rpm_drop, -gear_used_on_up_slope_1, -up_slope_rpm_drop_1, -gear_used_on_up_slope_2, -up_slope_rpm_drop_2, -gear_used_on_down_slope, -down_slope_rpm_shoot_up, -fuel_consumption_var_lit_per_hr, -mileage_var_km_per_ltr, -fuel_consumption_var_pct_lit_per_hr, -mileage_var_pct_km_per_ltr, -engine_smoke_on_load, -engine_acceleration_smoke, -range_gear_shifting, -speed_gear_shifting, -tractor_steer_ability, -tractor_braking_perf, -front_visibility, -implement_accessibility, -front_end_lifting_during_operation, -rpm_recovery_time, -engine_vibration, -engine_sound, -test_file_ref_no -) -select -client_id, -function_id, -Test_Condition, -Test_Date::date, -Tractor_Model, -Fuel_consumption_Ltr_hr::float fuel_consumption_lit_per_hr , -Mileage_Km_Ltr ::float mileage_km_per_ltr , -Average_speed_of_travel_kmph::float avg_speed_of_travel_kmph , -Total_distance_travelled_km::int total_dist_travelled_km , -Gear_used_on_Straight_Road, -Straight_road_RPM_Drop, -Gear_used_on_Up_Slope_1, -Up_Slope_RPM_Drop_1 , -Gear_used_on_Up_Slope_2, -Up_Slope_RPM_Drop_2, -Gear_used_on_Down_Slope, -Down_Slope_RPM_Shoot_up, -case when fuel_consumption_lit_hr_2 ~ E'^\\d+$' then fuel_consumption_lit_hr_2::int else null end as fuel_consumption_var_lit_per_hr , -case when Mileage_Km_Ltr_2 ~ E'^\\d+$' then Mileage_Km_Ltr_2::int else null end as mileage_var_km_per_ltr, -case when fuel_consumption_lit_hr_3 ~ E'^\\d+$' then fuel_consumption_lit_hr_3::int else null end as fuel_consumption_var_pct_lit_per_hr , -case when Mileage_Km_Ltr_3 ~ E'^\\d+$' then Mileage_Km_Ltr_3::int else null end as mileage_var_pct_km_per_ltr, -engine_smoke_on_load, -Engine_acceleration_smoke, -Range_Gear_Shifting, -Speed_Gear_Shifting, -Tractor_Steer_ability, -Tractor_braking_performance tractor_braking_perf , -Front_Visibility, -Implement_Accessibility, -Front_end_lifting_during_operation, -RPM_Recovery_Time, -Engine_Vibration, -Engine_Sound, -file_number -from mmt_staging2.fthlg_sum_test_condition_1_block where Gear_used_on_Straight_Road not in ('0','0.000')'; - - - -execute 'insert into mmt_ods.field_perf_summary -( -client_id, -function_id, -test_condition, -test_date, -tractor_model, -fuel_consumption_lit_per_hr, -mileage_km_per_ltr, -avg_speed_of_travel_kmph, ---total_dist_travelled_km, -gear_used_on_straight_road, -straight_road_rpm_drop, -gear_used_on_up_slope_1, -up_slope_rpm_drop_1, -gear_used_on_up_slope_2, -up_slope_rpm_drop_2, -gear_used_on_down_slope, -down_slope_rpm_shoot_up, -fuel_consumption_var_lit_per_hr, -mileage_var_km_per_ltr, -fuel_consumption_var_pct_lit_per_hr, -mileage_var_pct_km_per_ltr, -engine_smoke_on_load, -engine_acceleration_smoke, -range_gear_shifting, -speed_gear_shifting, -tractor_steer_ability, -tractor_braking_perf, -front_visibility, -implement_accessibility, -front_end_lifting_during_operation, -rpm_recovery_time, -engine_vibration, -engine_sound, -test_file_ref_no -) -select -client_id, -function_id, -Test_Condition, -Test_Date::date, -Tractor_Model, -Fuel_consumption_Ltr_hr::float fuel_consumption_lit_per_hr , -Mileage_Km_Ltr ::float mileage_km_per_ltr , -Average_speed_of_travel_kmph::float avg_speed_of_travel_kmph , -Total_distance_travelled_km::int end as total_dist_travelled_km , -Gear_used_on_Straight_Road, -Straight_road_RPM_Drop, -Gear_used_on_Up_Slope_1, -Up_Slope_RPM_Drop_1 , -Gear_used_on_Up_Slope_2, -Up_Slope_RPM_Drop_2, -Gear_used_on_Down_Slope, -Down_Slope_RPM_Shoot_up, -case when fuel_consumption_lit_hr_2 ~ E'^\\d+$' then fuel_consumption_lit_hr_2::int else null end as fuel_consumption_var_lit_per_hr , -case when Mileage_Km_Ltr_2 ~ E'^\\d+$' then Mileage_Km_Ltr_2::int else null end as mileage_var_km_per_ltr, -case when fuel_consumption_lit_hr_3 ~ E'^\\d+$' then fuel_consumption_lit_hr_3::int else null end as fuel_consumption_var_pct_lit_per_hr , -case when Mileage_Km_Ltr_3 ~ E'^\\d+$' then Mileage_Km_Ltr_3::int else null end as mileage_var_pct_km_per_ltr, -engine_smoke_on_load, -Engine_acceleration_smoke, -Range_Gear_Shifting, -Speed_Gear_Shifting, -Tractor_Steer_ability, -Tractor_braking_performance tractor_braking_perf , -Front_Visibility, -Implement_Accessibility, -Front_end_lifting_during_operation, -RPM_Recovery_Time, -Engine_Vibration, -Engine_Sound, -file_number -from mmt_staging2.fthlg_sum_test_condition_2_block where Gear_used_on_Straight_Road not in ('0','0.000')'; - - -end -$$ LANGUAGE plpgsql; - -select mmt_staging2.fn_FTHLG_SUM_ODS(); diff --git a/MMT_SQL/ods/FTHLG_TRS_ODS.sql b/MMT_SQL/ods/FTHLG_TRS_ODS.sql deleted file mode 100644 index 44c88f7..0000000 --- a/MMT_SQL/ods/FTHLG_TRS_ODS.sql +++ /dev/null @@ -1,194 +0,0 @@ -drop function if exists mmt_staging2.fn_FTHLG_TRS_ODS ; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTHLG_TRS_ODS() - RETURNS void AS $$ - begin - -execute 'insert into mmt_ods.test_instance -( -client_id, -function_id, -test_report_no, -objective_of_test, -background_of_test, -job_order_no, -test_location_name, -gradient_slope_1_degree, -gradient_slope_2_degree, -tractor_hitch_type, -test_engineer, -test_operator, -date_of_test, -test_report_date, -type_of_road, -tractor_hitch_ht_mm, -tractor_rwheel_c2h_dist_mm, -test_file_ref_no -) -select -client_id, -function_id, -Report_Reference_No test_report_no , -Objective_Of_Test, -Background_of_Test, -Job_Order_No, -Test_Location test_location_name, -Gradient_Slope_1_Degree::int, -Gradient_Slope_2_Degree::int, -Tractor_Hitch_Type, -Test_Engineer, -Test_Operator, -Date_of_Test::date, -Report_Date::date test_report_date, -Type_of_Road, -Tractor_Hitch_Height_from_Ground_mm::int tractor_hitch_ht_mm , -Tractor_Rear_Wheel_Center_to_Hitch_Point_Center_Distance_mm::int tractor_rwheel_c2h_dist_mm, -file_syspk -from mmt_staging2.FTHLG_TRS_H1_Block'; - - - -execute 'insert into mmt_ods.test_instance_tractor_info -( -client_id, -function_id, -tractor_model, -tractor_make, -tractor_sr_no, -tractor_engine_hp, -fip_type, -hour_meter_reading, -steering_type, -transmission_type, -wheel_drive_type, -egr_yn, -brake_type, -pto_type, -standard_pto_speed_rpm, -epto_speed_rpm, -tractor_weight_front_kg, -tractor_weight_rear_kg, -tractor_weight_total_kg, -ballasted_tractor_accessories, -mechanical_ballast_rear, -water_ballast_rear_75_pct, -mechanical_ballast_front_kg, -mechanical_ballast_front, -total_ballast_weight, -test_file_ref_no -) -select -client_id, -function_id, -Tractor_Model, -Tractor_Make, -Tractor_Sr_No, -Tractor_Engine_HP::int, -FIP_Type, -Hour_Meter_Reading::float, -Steering_Type, -Transmission_Type, -Wheel_Drive_Type_WD, -EGR_Yes_No egr_yn, -Brake_Type, -PTO_Type, -Standard_PTO_Speed_RPM::int, -EPTO_Speed_RPM::int, -Tractor_Weight_kg_Front::int tractor_weight_front_kg, -Tractor_Weight_kg_Rear::int tractor_weight_rear_kg, -Tractor_Weight_kg_Total::int tractor_weight_total_kg, -Ballasted_Tractor_Accessories, -Mechanical_Ballast_Rear, -Water_Ballast_Rear_75 water_ballast_rear_75_pct, -Mechanical_Ballast_Front_in_kg::int mechanical_ballast_front_kg, -Mechanical_Ballast_Front, -Total_Ballast_Weight::int, -file_syspk -from mmt_staging2.fthlg_trs_spec_block'; - - -execute 'insert into mmt_ods.test_instance_engine_info -( -client_id, -function_id, -low_idle_declared, -high_idle_declared, -rated_rpm, -engine_to_pto_ratio_540_pto, -engine_to_pto_ratio_540e_pto, -tractor_model, -tractor_make, -test_file_ref_no -) -select -client_id, -function_id, -low_idle low_idle_declared, -high_idle high_idle_declared, -rated_rpm::int, -engine_to_pto_ratio_540_pto, -engine_to_pto_ratio_540e_pto, -tractor_model, -tractor_make, -file_syspk -from mmt_staging2.fthlg_trs_engine_rpm_block where tractor_model is not null'; - - - -execute 'insert into mmt_ods.test_instance_trailer_info -( -client_id, -function_id, -type_of_trailer, -no_of_axle, -no_of_wheels, -trailer_hitch_ht_above_ground_lvl_mm, -make_model_of_trailer, -trailer_platform_length_mm, -trailer_platform_width_mm, -trailer_platform_height_mm, -tire_size, -inflation_pressure_psi, -track_width_of_trailer_mm, -hzntl_dist_of_hitch_pt_from_trailer_face_mm, -tractor_rwc_to_hitch_pt_center_dist_mm, -dist_from_tractor_rwc_to_trailer_rwc_mm, -dist_from_trailer_front_axle_dist_from_hitch_pt_mm, -trailer_empty_weight_kg, -trailer_gross_weight_kg, -test_file_ref_no -) -select -client_id, -function_id, -Type_Of_Trailer, -No_Of_Axle::int, -No_Of_Wheels::int, -Trailer_hitch_Height_above_ground_level_mm::int trailer_hitch_ht_above_ground_lvl_mm, -Make_model_of_trailer, -Trailer_platform_length_mm::int, -Trailer_platform_Width_mm::int, -Trailer_platform_Height_mm::int, -Tire_size, -Inflation_pressure_psi::int, -Track_width_of_trailer_mm::int, -Horizontal_distance_of_hitch_point_from_trailer_front_face_mm::int hzntl_dist_of_hitch_pt_from_trailer_face_mm, -Tractor_Rear_Wheel_Center_to_Hitch_Point_Center_Distance_mm::int tractor_rwc_to_hitch_pt_center_dist_mm, -Distance_from_Trailerfront_axle_distance_from_hitch_point_mm::int dist_from_tractor_rwc_to_trailer_rwc_mm, -Distance_from_tractor_rear_wheel_center_to_tractor_rear_wheel_center_mm::int dist_from_trailer_front_axle_dist_from_hitch_pt_mm, -Trailer_empty_weight_Kg::int, -Trailer_Gross_Weight_Kg::int, -file_syspk -from mmt_staging2.fthlg_trs_trailer_block'; - - -end -$$ LANGUAGE plpgsql; - -select mmt_staging2.fn_FTHLG_TRS_ODS(); - - - -end -$$ LANGUAGE plpgsql; - -select mmt_staging2.fn_FTHLG_TRS_ODS (); diff --git a/MMT_SQL/ods/FTWET_SUM_ODS.sql b/MMT_SQL/ods/FTWET_SUM_ODS.sql deleted file mode 100644 index 3e16d12..0000000 --- a/MMT_SQL/ods/FTWET_SUM_ODS.sql +++ /dev/null @@ -1,185 +0,0 @@ - -drop function if exists mmt_staging2.fn_FTWET_SUM_ODS ; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTWET_SUM_ODS() - RETURNS void AS $$ - begin - -execute 'insert into mmt_ods.field_perf_summary_tractor_info -( -client_id, -function_id, -tractor_model, -tractor_make, -tractor_engine_hp, -rated_rpm, -transmission_type, -wheel_drive_type, -fip_type, -steering_type, -tractor_weight_front_kg, -tractor_weight_rear_kg, -tractor_weight_total_kg, -test_file_ref_no -) -select -client_id, -function_id -tractor_model, -tractor_make, -tractor_engine_hp::float, -rated_rpm::int, -transmission_type, -wheel_drive_type, -fip_type, -steering_type, -tractor_weight_kg_front::int, -tractor_weight_kg_rear::int, -tractor_weight_kg_total::int, -file_number, -from mmt_staging2.ftwet_sum_trac_h1_block where tractor_model<> '0''; - -execute 'insert into mmt_ods.field_perf_summary_implement_info -( -client_id, -function_id, -make_of_implement, -implement_type, -implement_size, -hitch_category, -implement_weight, -soil_type, -soil_moisture_content_pct, -soil_bulk_density_g_per_cc, -soil_cone_index, -field_condition, -season, -test_file_ref_no, -) -select -client_id, -function_id, -make_of_implement, -implement_type, -implement_size, -hitch_category, -implement_weight::int, -soil_type, -moisture_content::int soil_moisture_content_pct, -bulk_density_g_cc::int soil_bulk_density_g_per_cc, -soil_cone_index::int soil_cone_index, -field_condition, -season, -file_number -from mmt_staging2.ftwet_sum_implement_block'; - -execute 'insert into mmt_ods.field_perf_summary_implement_info -( -client_id, -function_id, -type_of_cage_wheel, -cage_wheel_width_mm, -cage_wheel_weight, -cage_wheel_inner_and_outer_ring_dia_mm, -cage_wheel_center_ring_dia_mm, -dist_between_rhs_and_lhs_cage_wheel_inner_ring_mm, -no_of_angles_on_cage_wheel, -test_file_ref_no -) -select -client_id, -function_id, -Type_of_Cage_Wheel, -Cage_Wheel_Width_mm::int, -Cage_wheel_Weight::int, -Cage_Wheel_inner_Outer_Ring_Dia_mm::int cage_wheel_inner_and_outer_ring_dia_mm , -Cage_Wheel_Center_Ring_Dia_mm::int, -Distance_between_RHS_LHS_cage_wheel_Inner_Ring_mm::int dist_between_rhs_and_lhs_cage_wheel_inner_ring_mm , -No_of_angles_on_cage_wheel::int, -file_number -from mmt_staging2.FTWET_SUM_Cage_Wheel_Block'; - - -execute 'insert into mmt_ods.field_perf_summary -( -Test_Condition, -Test_Date, -Tractor_Model, -Engine_RPM_set, -PTO_RPM_set, -Gear_Used, -Nominal_Speed_KMPH, -Engine_RPM_Drop_on_straight_1st_Pass, -Engine_RPM_Drop_on_straight_2nd_Pass, -Engine_RPM_Drop_on_straight_3rd_Pass, -Engine_RPM_Drop_on_turn_1st_Pass, -Engine_RPM_Drop_on_turn_2nd_Pass, -Engine_RPM_Drop_on_turn_3rd_Pass, -No_of_passes, -depth_of_cut_cm, -fuel_consumption_lit_per_hr, -area_covered_acr_per_hr, - fuel_consumption_lit_per_acr, - fuel_consumption_var_lit_per_hr, -area_covered_var_acr_per_hr, -fuel_consumption_var_lit_per_acr, -Engine_Smoke_on_Load, -Engine_acceleration_smoke, -Draft_Response, -Tractor_Steer_ability, -Tractor_braking_perf, -Front_Visibility, -Implement_Accessibility, -Front_Wheel_dragging_at_turning, -Front_end_lifting_during_operation, -RPM_Recovery_Time, -Engine_Vibration, -Engine_Sound, -implement_lifting_per_lowering_response, -Pulverization_Quality, -Pulverization_Index, -test_file_ref_no -) -select -Test_Condition, -Test_Date::date, -Tractor_Model, -Engine_RPM_set::int, -PTO_RPM_set::int, -Gear_Used, -Nominal_Speed_KMPH::float, -Engine_RPM_Drop_on_straight_1st_Pass, -Engine_RPM_Drop_on_straight_2nd_Pass, -Engine_RPM_Drop_on_straight_3rd_Pass, -Engine_RPM_Drop_on_turn_1st_Pass, -Engine_RPM_Drop_on_turn_2nd_Pass, -Engine_RPM_Drop_on_turn_3rd_Pass, -No_of_passes::int, -Avg_Depth_of_cut_cm depth_of_cut_cm , -Fuel_consumption_lit_hr::float fuel_consumption_lit_per_hr, -Area_covered_acr_hr::float area_covered_acr_per_hr, -Fuel_consumption_lit_Acr::float fuel_consumption_lit_per_acr, -Fuel_consumption_lit_hr_2::int fuel_consumption_var_lit_per_hr, -Area_covered_acr_hr_2::int area_covered_var_acr_per_hr, -Fuel_consumption_lit_Acr_2::int fuel_consumption_var_lit_per_acr, -Engine_Smoke_on_Load, -Engine_acceleration_smoke, -Draft_Response, -Tractor_Steer_ability, -Tractor_braking_performance tractor_braking_perf, -Front_Visibility, -Implement_Accessibility, -Front_Wheel_dragging_at_turning, -Front_end_lifting_during_operation, -RPM_Recovery_Time, -Engine_Vibration, -Engine_Sound, -Implement_Lifting_Lowering_response implement_lifting_per_lowering_response, -Pulverization_Quality, -Pulverization_Index, -file_number -from mmt_staging2.FTWET_SUM_Test_Condition_Block where engine_rpm_set <> '0''; - -end -$$ LANGUAGE plpgsql; - -select mmt_staging2.fn_FTWET_SUM_ODS(); diff --git a/MMT_SQL/ods/FTWET_TRS_ODS.sql b/MMT_SQL/ods/FTWET_TRS_ODS.sql deleted file mode 100644 index 52e470d..0000000 --- a/MMT_SQL/ods/FTWET_TRS_ODS.sql +++ /dev/null @@ -1,193 +0,0 @@ - -drop function if exists mmt_staging2.fn_FTWET_TRS_ODS ; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTWET_TRS_ODS() - RETURNS void AS $$ - begin - -execute 'insert into mmt_ods.test_instance -( -client_id, -function_id, -test_file_ref_no , -test_report_no, -objective_of_test, -background_of_test, -job_order_no, -test_location_name, -soil_moisture_content_pct, -soil_bulk_density_g_per_cc, -test_engineer, -test_operator, -date_of_test, -test_report_date, -season, -type_of_soil, -soil_cone_index, -field_condition -) -select client_id, -function_id, -file_number, -report_reference_no test_report_no, -objective_of_test, -background_of_test, -job_order_no, -test_location test_location_name, -soil_moisture_content_::int soil_moisture_content_pct , -soil_bulk_density_g_cc::int soil_bulk_density_g_per_cc, -test_engineer, -test_operator, -date_of_test::date, -report_date::date test_report_date, -season, -type_of_soil, -soil_cone_index_kpa::int soil_cone_index, -field_condition -from mmt_staging2.ftwet_trs_h1_block'; - - -execute 'insert into mmt_ods.test_instance_tractor_info -( -client_id, -function_id, -tractor_model, -tractor_make, -tractor_sr_no, -tractor_engine_hp, -fip_type, -hour_Meter_Reading, -Steering_Type, -Transmission_Type, -wheel_drive_type, -egr_yn, -Brake_Type, -PTO_Type, -Standard_PTO_Speed_RPM, -EPTO_Speed_RPM, -tractor_weight_front_kg, -tractor_weight_rear_kg, -tractor_weight_total_kg, -Ballasted_Tractor_Accessories, -mechanical_ballast_rear_in_kg, -water_ballast_rear_75_pct , -Mechanical_Ballast_Front, -mechanical_ballast_front_kg , -Total_Ballast_Weight, -test_file_ref_no -) -select client_id, -function_id, -Tractor_Model, -Tractor_Make, -Tractor_Sr_No, -Tractor_Engine_HP::float, -FIP_Type, -hour_Meter_Reading::float, -Steering_Type, -Transmission_Type, -Wheel_Drive_Type_WD wheel_drive_type , -EGR_Yes_No egr_yn, -Brake_Type , -PTO_Type , -Standard_PTO_Speed_RPM::int, -EPTO_Speed_RPM::int, -Tractor_Weight_kg_Front::int tractor_weight_front_kg , -Tractor_Weight_kg_Rear::int tractor_weight_rear_kg , -Tractor_Weight_kg_Total::int tractor_weight_total_kg , -Ballasted_Tractor_Accessories, -Mechanical_Ballast_Rear_in_KG::int mechanical_ballast_rear_in_kg , -Water_Ballast_Rear water_ballast_rear_75_pct , -Mechanical_Ballast_Front, -Mechanical_Ballast_Front_in_Kg::int mechanical_ballast_front_kg , -Total_Ballast_Weight::int, -file_number -from mmt_staging2.ftwet_trs_spec_block where tractor_model is not null'; - - - -execute 'insert into mmt_ods.test_instance_engine_info -( -client_id, -function_id, -low_idle_declared, -high_idle_declared, -rated_rpm_declared, -engine_to_pto_ratio_540_pto, -engine_to_pto_ratio_540e_pto, -test_file_ref_no, -) -select -client_id, -function_id, -low_idle low_idle_declared, -high_idle high_idle_declared, -rated_rpm::int rated_rpm_declared, -engine_to_pto_ratio_540_pto, -engine_to_pto_ratio_540e_pto, -file_number - from mmt_staging2.ftwet_trs_engine_rpm_block tractor_model is not null '; - - - -execute 'insert into mmt_ods.test_instance_implement_info -( -client_id, -function_id, -name_of_implement, -type_of_implement, -make_of_implement, -no_of_disc_blades_bottoms, -cutting_width_m, -implement_weight_kg, -hitch_category, -span_for_mounted_implement_cm, -mast_height_for_mounted_implement_cm, -type_of_cage_wheel_hcw_fcw, -Cage_Wheel_Width_mm, -cage_wheel_weight_kg, -cage_wheel_inner_ring_dia_mm, -cage_wheel_outer_ring_dia_mm, -cage_wheel_center_ring_dia_mm, -dist_btwn_lhs_fcw_to_rhs_fcw_mm, -No_of_angles_on_cage_wheel, -No_of_days_of_water_logging, -Depth_of_water_mm, -test_file_ref_no -) -select -client_id,function_id, -name_of_implement, -type_of_implement, -make_of_implement, -no_of_bottoms_tyne_disc_blade::int no_of_disc_blades_bottoms, -cutting_width_m, -implement_weight_kg::int, -hitch_category, -span_cm_for_mounted_implement::int span_for_mounted_implement_cm , -mast_height_cm_for_mounted_implement::int mast_height_for_mounted_implement_cm, -Type_of_Cage_Wheel_Half_Cage_wheel_Full_Cage_Wheel type_of_cage_wheel_hcw_fcw , -Cage_Wheel_Width_mm::int, -Cage_wheel_Weight::int cage_wheel_weight_kg, -Cage_Wheel_inner_Outer_Ring_Dia_mm::int cage_wheel_inner_ring_dia_mm , -Cage_Wheel_inner_Outer_Ring_Dia_mm::int cage_wheel_outer_ring_dia_mm, -Cage_Wheel_Center_Ring_Dia_mm::int cage_wheel_center_ring_dia_mm , -Distance_between_RHS_LHS_cage_wheel_Inner_Ring_mm_For_Full_Cage_wheel::int dist_btwn_lhs_fcw_to_rhs_fcw_mm, -No_of_angles_on_cage_wheel::int, -No_of_days_of_water_logging::int, -Depth_of_water_mm::int, -file_number -from mmt_staging2.ftwet_trs_implement_block where name_of_implement is not null'; - - -end -$$ LANGUAGE plpgsql; - - -select mmt_staging2.fn_FTWET_TRS_ODS(); - - - -end -$$ LANGUAGE plpgsql; - - diff --git a/MMT_SQL/ods/PTO-GVG_ods.txt b/MMT_SQL/ods/PTO-GVG_ods.txt new file mode 100644 index 0000000..390268c --- /dev/null +++ b/MMT_SQL/ods/PTO-GVG_ods.txt @@ -0,0 +1,160 @@ +drop function if exists mmt_staging2.fn_PTO_GVG_ODS; +CREATE OR REPLACE FUNCTION mmt_staging2.fn_PTO_GVG_ODS() + RETURNS void AS $$ + begin + SET search_path TO mmt_staging2; + + +/************************************************************* +Function Name:fn_PTO_GVG_ODS +Function Desc: This function populates data into ODS blocks +File Format: PTOBST +Sheet Format: PTOBST_GVG +Creation Date: March 21 2021 +Updation Date: +Author: compegence team +Function Call: select mmt_staging2.fn_PTO_GVG_ODS() +***************************************************************/ + + +insert into mmt_ods.PTO_Perf_Governing_Graph +(client_id, +function_id, +test_file_ref_no, +tractor_model, +tractor_make, +test_condition, +engine_speed_rpm, +torque_kg_m, +power_hp, +sfc_gm_per_hp_hr, +fuelling_mm3_per_stroke_per_cyl, +test_file_format, +test_file_sheet_format) +select +client_id, +function_id, +file_syspk, +model, +make, +c1, +c2::numeric, +c3::numeric, +c4::numeric, +c5::numeric, +c6::numeric, +file_format, +sheet_mnemonic +from mmt_staging2.PTOBST_GVG_performance_governing_trails_block +where ods_record=1 +union +select +client_id, +function_id, +file_syspk, +model, +make, +c7_1, +c7::numeric, +c8::numeric, +c9::numeric, +c10::numeric, +c11::numeric, +file_format, +sheet_mnemonic +from mmt_staging2.PTOBST_GVG_performance_governing_trails_block +where ods_record=1 +and (c7 is not null and c8 is not null and c9 is not null and c10 is not null and c11 is not null) +union +select +client_id, +function_id, +file_syspk, +model, +make, +c12_1, +c12::numeric, +c13::numeric, +c14::numeric, +c15::numeric, +c16::numeric, +file_format, +sheet_mnemonic +from mmt_staging2.PTOBST_GVG_performance_governing_trails_block +where ods_record=1 +and (c12 is not null and c13 is not null and c14 is not null and c15 is not null and c16 is not null) +union +select +client_id, +function_id, +file_syspk, +model, +make, +c17_1, +c17::numeric, +c18::numeric, +c19::numeric, +c20::numeric, +c21::numeric, +file_format, +sheet_mnemonic +from mmt_staging2.PTOBST_GVG_performance_governing_trails_block +where ods_record=1 +and (c17 is not null and c18 is not null and c19 is not null and c20 is not null and c21 is not null) +union +select +client_id, +function_id, +file_syspk, +model, +make, +c22_1, +c22::numeric, +c23::numeric, +c24::numeric, +c25::numeric, +c26::numeric, +file_format, +sheet_mnemonic +from mmt_staging2.PTOBST_GVG_performance_governing_trails_block +where ods_record=1 +and (c22 is not null and c23 is not null and c24 is not null and c25 is not null and c26 is not null) +union +select +client_id, +function_id, +file_syspk, +model, +make, +c27_1, +c27::numeric, +c28::numeric, +c29::numeric, +c30::numeric, +c31::numeric, +file_format, +sheet_mnemonic +from mmt_staging2.PTOBST_GVG_performance_governing_trails_block +where ods_record=1 +and (c27 is not null and c28 is not null and c29 is not null and c30 is not null and c32 is not null) +union +select +client_id, +function_id, +file_syspk, +model, +make, +c32_1, +c32::numeric, +c33::numeric, +c34::numeric, +c35::numeric, +c36::numeric, +file_format, +sheet_mnemonic +from mmt_staging2.PTOBST_GVG_performance_governing_trails_block +where ods_record=1 +and (c32 is not null and c33 is not null and c34 is not null and c35 is not null and c36 is not null); + + end +$$ LANGUAGE plpgsql; diff --git a/MMT_SQL/ods/PTO-MPM_ods.txt b/MMT_SQL/ods/PTO-MPM_ods.txt new file mode 100644 index 0000000..df09806 --- /dev/null +++ b/MMT_SQL/ods/PTO-MPM_ods.txt @@ -0,0 +1,34 @@ +drop function if exists mmt_staging2.fn_PTO_MPM_ODS; +CREATE OR REPLACE FUNCTION mmt_staging2.fn_PTO_MPM_ODS() + RETURNS void AS $$ +begin + + +/************************************************************* +Function Name:fn_PTO_MPM_ODS +Function Desc: This function populates data into ODS blocks +File Format: PTOBST +Sheet Format: PTOBST_MPM +Creation Date: March 21 2021 +Updation Date: +Author: compegence team +Function Call: select mmt_staging2.fn_PTO_MPM_ODS() +***************************************************************/ + + insert into mmt_ods.PTO_Multipoint_Mapping +( +client_id,function_id,test_file_ref_no,test_file_format,test_file_sheet_format, +tractor_make ,tractor_model , +test_condition, +engine_speed_rpm, +engine_load_pct, +sfc_gm_per_hp_hr, +fuel_consumption_ltr_per_hr +) + +select client_id,function_id,file_syspk,file_format,sheet_mnemonic,make,model,test_condition, +c2::numeric,c3::numeric,c4::numeric,c5::numeric +from mmt_staging2.PTOBST_MPM_performance_boost_natuaral_block +where ods_record=1 ; +end +$$ LANGUAGE plpgsql; diff --git a/MMT_SQL/ods/PTO-PHA_ods.txt b/MMT_SQL/ods/PTO-PHA_ods.txt new file mode 100644 index 0000000..fc89086 --- /dev/null +++ b/MMT_SQL/ods/PTO-PHA_ods.txt @@ -0,0 +1,104 @@ +drop function if exists mmt_staging2.fn_PTO_PHA_ODS; +CREATE OR REPLACE FUNCTION mmt_staging2.fn_PTO_PHA_ODS() + RETURNS void AS $$ + begin + +/************************************************************* +Function Name:fn_PTO_PHA_ODS +Function Desc: This function populates data into ODS blocks +File Format: PTOBST +Sheet Format: PTOBST_PHA +Creation Date: March 21 2021 +Updation Date: +Author: compegence team +Function Call: select mmt_staging2.fn_PTO_PHA_ODS() +***************************************************************/ + + + SET search_path TO mmt_staging2; + insert into mmt_ods.PTO_Key_Perf_Parameters +(client_id,function_id,test_condtion,test_file_ref_no, +tractor_model,tractor_make,pto_gear_ratio,specific_gravity_of_fuel,dyno_constant,pto_power_hp, +pto_sfc_gm_per_hp_hr,backup_torque_pct,engine_oil_temp_c,coolant_temp_c,rated_engine_speed_rpm, +engine_high_idle_speed_rpm,engine_low_idle_speed_rpm,maximum_equi_crankshaft_torque_nm, +equi_crankshaft_torque_at_max_power_nm,ambient_presure_mm_of_hg,related_humidity_pct, +exhaust_temperature_c,back_pressure_mm_of_hg,engine_oil_pressure_bar,test_engineer,test_bed, +location_name,total_run_hrs,test_date,test_file_format,test_file_sheet_format +) +select +client_id,function_id,test_condition,file_syspk, +model,make,pto_gear_ratio::numeric,specific_gravity_of_fuel::numeric,dyno_constant::numeric,pto_power_hp::numeric, +pto_sfc_gm_hp::numeric,backup_torque::numeric,engine_oil_temp::numeric,coolant_temp::numeric, +rated_engine_speed::numeric,engine_high_idle_speed::numeric,engine_low_idle_speed::numeric, +maximum_equ_crankshaft::numeric,equ_crankshaft_torque_at_maximum_power::numeric, +ambient_pressure_mm_of_hg::numeric,relative_humidity::numeric, +exhaust_temperature::numeric,back_pressure::numeric,engine_oil_pressure_bar::numeric,test_engineer,test_bed, +place,total_run_hrs::int, to_Date(test_Date, 'DD-MM-YYYY'),file_format,sheet_mnemonic +from mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_block +where ods_record=1; + + +/* block */ +insert into mmt_ods.PTO_Perf_Results +( +client_id,function_id,test_file_ref_no,test_file_format,test_file_sheet_format, +tractor_make, +tractor_model, +pto_test_type,serial_number,speed_engine_rpm, +speed_pto_rpm,torque_n_m,torque_kg_m,power_kw, +power_hp,eq_crank_torque_nm,fuel_consumption_g_per_min,fuel_consumption_kg_per_hr, +fuel_consumption_ltr_per_hr,fuel_consumption_sfc_kg_per_kwh,fuel_consumption_sfc_g_per_hph, +sp_energy_kwh_per_ltr,temperatures_fuel_c,temperatures_ambient_c,temperatures_air_in_c, +temperatures_water_outlet_c,temperatures_exh_c,engine_oil_c,pressure_ambient_mm_of_hg,pressure_exh_mm_of_hg, +pressure_lub_oil_bar,rh_pct +) + +select client_id,function_id,file_syspk,file_format,sheet_mnemonic,make,model, +test_condition,c2,c3::numeric,c4::numeric,c5::numeric,c6::numeric,c7::numeric,c8::numeric,c9::numeric,c10::numeric, +c11::numeric, +c12::numeric,c13::numeric,c14::numeric,c15::numeric,c16::numeric,c17::numeric,c18::numeric, +c19::numeric,c20::numeric,c21::numeric,c22::numeric,c23::numeric,c24::numeric,c25::numeric +from mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block +where ods_record=1 ; + +/* block */ +insert into mmt_ods.PTO_Perf_Results +( +client_id,function_id,test_file_ref_no,test_file_format,test_file_sheet_format, +tractor_make, +tractor_model, +pto_test_type,serial_number,speed_engine_rpm, +speed_pto_rpm,torque_n_m,torque_kg_m,power_kw, +power_hp,eq_crank_torque_nm,fuel_consumption_g_per_min,fuel_consumption_kg_per_hr, +fuel_consumption_ltr_per_hr,fuel_consumption_sfc_kg_per_kwh,fuel_consumption_sfc_g_per_hph, +sp_energy_kwh_per_ltr,temperatures_fuel_c,temperatures_ambient_c,temperatures_air_in_c, +temperatures_water_outlet_c,temperatures_exh_c,engine_oil_c,pressure_ambient_mm_of_hg,pressure_exh_mm_of_hg, +pressure_lub_oil_bar,rh_pct +) + +select client_id,function_id,file_syspk,file_format,sheet_mnemonic,make,model, +test_condition,c2,c3::numeric,c4::numeric,c5::numeric,c6::numeric,c7::numeric,c8::numeric,c9::numeric,c10::numeric, +c11::numeric, +c12::numeric,c13::numeric,c14::numeric,c15::numeric,c16::numeric,c17::numeric,c18::numeric, +c19::numeric,c20::numeric,c21::numeric,c22::numeric,c23::numeric,c24::numeric,c25::numeric + from mmt_staging2.PTOBST_PHA_varying_speed_test_block +where ods_record=1 ; + +/* block */ +insert into mmt_ods.pto_engine_oil_consumption +( +client_id,function_id,test_file_ref_no,test_file_format,test_file_sheet_format, +tractor_make, +tractor_model, +srl_no, +oil_consumption_gm_per_hr, +oil_consumption_pct_of_fuel_consumption +) + +select client_id,function_id,file_syspk,file_format,sheet_mnemonic,make,model, +c2::int,c3::numeric,c5::numeric +from mmt_staging2.PTOBST_PHA_Engine_oil_consumption_block +where ods_record=1; + + end +$$ LANGUAGE plpgsql; \ No newline at end of file diff --git a/MMT_SQL/ods/PTO-PNA-ods.txt b/MMT_SQL/ods/PTO-PNA-ods.txt new file mode 100644 index 0000000..2f5592a --- /dev/null +++ b/MMT_SQL/ods/PTO-PNA-ods.txt @@ -0,0 +1,176 @@ +drop function if exists mmt_staging2.fn_PTO_PNA_ODS; +CREATE OR REPLACE FUNCTION mmt_staging2.fn_PTO_PNA_ODS() + RETURNS void AS $$ + begin + +/************************************************************* +Function Name:fn_PTO_PNA_ODS +Function Desc: This function populates data into ODS blocks +File Format: PTOBST +Sheet Format: PTOBST_PNA +Creation Date: March 21 2021 +Updation Date: +Author: compegence team +Function Call: select mmt_staging2.fn_PTO_PNA_ODS() +***************************************************************/ + + + SET search_path TO mmt_staging2; + insert into mmt_ods.PTO_Key_Perf_Parameters +(client_id,function_id,test_condtion,test_file_ref_no, +tractor_model,tractor_make,pto_gear_ratio,specific_gravity_of_fuel,dyno_constant,pto_power_hp, +pto_sfc_gm_per_hp_hr,backup_torque_pct,engine_oil_temp_c,coolant_temp_c,rated_engine_speed_rpm, +engine_high_idle_speed_rpm,engine_low_idle_speed_rpm,maximum_equi_crankshaft_torque_nm, +equi_crankshaft_torque_at_max_Power_Nm,ambient_presure_mm_of_hg,related_humidity_pct, +exhaust_temperature_c,back_pressure_mm_of_hg,engine_oil_pressure_bar,test_engineer,test_bed, +location_name,total_run_hrs,test_date,test_file_format,test_file_sheet_format +) +select +client_id,function_id,test_condition,file_syspk, +model,make,pto_gear_ratio::numeric,specific_gravity_of_fuel::numeric,dyno_constant::numeric,pto_power_hp::numeric, +pto_sfc_gm_hp::numeric,backup_torque::numeric,engine_oil_temp::numeric,coolant_temp::numeric, +rated_engine_speed::numeric,engine_high_idle_speed::numeric,engine_low_idle_speed::numeric, +maximum_equ_crankshaft::numeric,equ_crankshaft_torque_at_maximum_power::numeric, +ambient_pressure_mm_of_hg::numeric,relative_humidity::numeric, +exhaust_temperature::numeric,back_pressure::numeric,engine_oil_pressure_bar::numeric,test_engineer,test_bed, +place,total_run_hrs::int, to_Date(test_Date, 'DD-MM-YYYY'),file_format,sheet_mnemonic +from mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_block +where ods_record=1; + +/* block */ +insert into mmt_ods.PTO_Perf_Results +( +client_id,function_id,test_file_ref_no,test_file_format,test_file_sheet_format, +tractor_make, +tractor_model, +pto_test_type,serial_number,speed_engine_rpm, +speed_pto_rpm,torque_n_m,torque_kg_m,power_kw, +power_hp,eq_crank_torque_nm,fuel_consumption_g_per_min,fuel_consumption_kg_per_hr, +fuel_consumption_ltr_per_hr,fuel_consumption_sfc_kg_per_kwh,fuel_consumption_sfc_g_per_hph, +sp_energy_kwh_per_ltr,temperatures_fuel_c,temperatures_ambient_c,temperatures_air_in_c, +temperatures_water_outlet_c,temperatures_exh_c,engine_oil_c,pressure_ambient_mm_of_hg,pressure_exh_mm_of_hg, +pressure_lub_oil_bar,rh_pct +) + +select client_id,function_id,file_syspk,file_format,sheet_mnemonic,make,model, +test_condition,c2,c3::int,c4::numeric,c5::numeric,c6::numeric,c7::numeric,c8::numeric,c9::numeric,c10::numeric, +c11::numeric, +c12::numeric,c13::numeric,c14::numeric,c15::numeric,c16::numeric,c17::numeric,c18::numeric, +c19::numeric,c20::numeric,c21::numeric,c22::numeric,c23::numeric,c24::numeric,c25::numeric + from mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block +where ods_record=1; + +/* block */ +insert into mmt_ods.PTO_Perf_Results +( +client_id,function_id,test_file_ref_no,test_file_format,test_file_sheet_format, +tractor_make, +tractor_model, +pto_test_type,serial_number,speed_engine_rpm, +speed_pto_rpm,torque_n_m,torque_kg_m,power_kw, +power_hp,eq_crank_torque_nm,fuel_consumption_g_per_min,fuel_consumption_kg_per_hr, +fuel_consumption_ltr_per_hr,fuel_consumption_sfc_kg_per_kwh,fuel_consumption_sfc_g_per_hph, +sp_energy_kwh_per_ltr,temperatures_fuel_c,temperatures_ambient_c,temperatures_air_in_c, +temperatures_water_outlet_c,temperatures_exh_c,engine_oil_c,pressure_ambient_mm_of_hg,pressure_exh_mm_of_hg, +pressure_lub_oil_bar,rh_pct +) + +select client_id,function_id,file_syspk,file_format,sheet_mnemonic,make,model, +test_condition,c2,c3::numeric,c4::numeric,c5::numeric,c6::numeric,c7::numeric,c8::numeric,c9::numeric,c10::numeric, +c11::numeric, +c12::numeric,c13::numeric,c14::numeric,c15::numeric,c16::numeric,c17::numeric,c18::numeric, +c19::numeric,c20::numeric,c21::numeric,c22::numeric,c23::numeric,c24::numeric,c25::numeric +from mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block +where ods_record=1 ; +/*and c2<>'Avg' */ + +/* block */ +insert into mmt_ods.PTO_Perf_Results +( +client_id,function_id,test_file_ref_no,test_file_format,test_file_sheet_format, +tractor_make, +tractor_model, +pto_test_type,serial_number,speed_engine_rpm, +speed_pto_rpm,torque_n_m,torque_kg_m,power_kw, +power_hp,eq_crank_torque_nm,fuel_consumption_g_per_min,fuel_consumption_kg_per_hr, +fuel_consumption_ltr_per_hr,fuel_consumption_sfc_kg_per_kwh,fuel_consumption_sfc_g_per_hph, +sp_energy_kwh_per_ltr,temperatures_fuel_c,temperatures_ambient_c,temperatures_air_in_c, +temperatures_water_outlet_c,temperatures_exh_c,engine_oil_c,pressure_ambient_mm_of_hg,pressure_exh_mm_of_hg, +pressure_lub_oil_bar,rh_pct +) + +select client_id,function_id,file_syspk,file_format,sheet_mnemonic,make,model, +test_condition,c2,c3::int,c4::numeric,c5::numeric,c6::numeric,c7::numeric,c8::numeric,c9::numeric,c10::numeric, +c11::numeric, +c12::numeric,c13::numeric,c14::numeric,c15::numeric,c16::numeric,c17::numeric,c18::numeric, +c19::numeric,c20::numeric,c21::numeric,c22::numeric,c23::numeric,c24::numeric,c25::numeric +from mmt_staging2.PTOBST_PNA_varying_speed_test_block +where ods_record=1 ; + +/* block */ +insert into mmt_ods.PTO_Perf_Results +( +client_id,function_id,test_file_ref_no,test_file_format,test_file_sheet_format, +tractor_make, +tractor_model, +pto_test_type,pto_test_sub_type,serial_number,speed_engine_rpm, +speed_pto_rpm,torque_n_m,torque_kg_m,power_kw, +power_hp,eq_crank_torque_nm,fuel_consumption_g_per_min,fuel_consumption_kg_per_hr, +fuel_consumption_ltr_per_hr,fuel_consumption_sfc_kg_per_kwh,fuel_consumption_sfc_g_per_hph, +sp_energy_kwh_per_ltr,temperatures_fuel_c,temperatures_ambient_c,temperatures_air_in_c, +temperatures_water_outlet_c,temperatures_exh_c,engine_oil_c,pressure_ambient_mm_of_hg,pressure_exh_mm_of_hg, +pressure_lub_oil_bar,rh_pct +) + +select client_id,function_id,file_syspk,file_format,sheet_mnemonic,make,model, +test_condition,c1,c2,c3::numeric,c4::numeric,c5::numeric,c6::numeric,c7::numeric,c8::numeric,c9::numeric,c10::numeric, +c11::numeric, +c12::numeric,c13::numeric,c14::numeric,c15::numeric,c16::numeric,c17::numeric,c18::numeric, +c19::numeric,c20::numeric,c21::numeric,c22::numeric,c23::numeric,c24::numeric,c25::numeric +from mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block +where ods_record=1 ; + +/* block */ +insert into mmt_ods.PTO_Perf_Results +( +client_id,function_id,test_file_ref_no,test_file_format,test_file_sheet_format, +tractor_make, +tractor_model, +pto_test_type,pto_test_sub_type,serial_number,speed_engine_rpm, +speed_pto_rpm,torque_n_m,torque_kg_m,power_kw, +power_hp,eq_crank_torque_nm,fuel_consumption_g_per_min,fuel_consumption_kg_per_hr, +fuel_consumption_ltr_per_hr,fuel_consumption_sfc_kg_per_kwh,fuel_consumption_sfc_g_per_hph, +sp_energy_kwh_per_ltr,temperatures_fuel_c,temperatures_ambient_c,temperatures_air_in_c, +temperatures_water_outlet_c,temperatures_exh_c,engine_oil_c,pressure_ambient_mm_of_hg,pressure_exh_mm_of_hg, +pressure_lub_oil_bar,rh_pct +) + +select client_id,function_id,file_syspk,file_format,sheet_mnemonic,make,model, +test_condition,c1,c2,c3::numeric,c4::numeric,c5::numeric,c6::numeric,c7::numeric,c8::numeric,c9::numeric,c10::numeric, +c11::numeric, +c12::numeric,c13::numeric,c14::numeric,c15::numeric,c16::numeric,c17::numeric,c18::numeric, +c19::numeric,c20::numeric,c21::numeric,c22::numeric,c23::numeric,c24::numeric,c25::numeric +from mmt_staging2.PTOBST_PNA_varying_load_block +where ods_record=1 ; + +/* block */ +insert into mmt_ods.pto_smoke_test +( +client_id,function_id,test_file_ref_no,test_file_format,test_file_sheet_format, +tractor_make, +tractor_model, +engine_speed_rpm, +pto_speed_rpm , +torque_100_pct , +torque_80_pct , +smoke_fsn_100_pct , +smoke_fsn_80_pct +) + +select client_id,function_id,file_syspk,file_format,sheet_mnemonic,make,model, +c2::numeric,c3::numeric,c4::numeric,c5::numeric,c6::numeric,c7::numeric +from mmt_staging2.PTOBST_PNA_smoke_test_block +where ods_record=1 ; + end +$$ LANGUAGE plpgsql; + diff --git a/MMT_SQL/ods/BUDNI_PTO_ODS.SQL b/MMT_SQL/ods/PTO-RPT-ods.txt similarity index 57% rename from MMT_SQL/ods/BUDNI_PTO_ODS.SQL rename to MMT_SQL/ods/PTO-RPT-ods.txt index c081c2f..c248db4 100644 --- a/MMT_SQL/ods/BUDNI_PTO_ODS.SQL +++ b/MMT_SQL/ods/PTO-RPT-ods.txt @@ -1,5 +1,5 @@ -drop function if exists mmt_staging2.fn_BUDNI_PTO_ODS; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_BUDNI_PTO_ODS() +drop function if exists mmt_staging2.fn_PTO_report_ODS; +CREATE OR REPLACE FUNCTION mmt_staging2.fn_PTO_report_ODS() RETURNS void AS $$ begin @@ -27,11 +27,9 @@ function_id, file_syspk, file_format, sheet_mnemonic, -make, -model, -tractor_HP::int, -configuration,FIP_type,steering_type,transmission_type,wheel_drive_type -from mmt_staging2.BUDNI_PTO_Spec_H1_block; +make,model,tractor_HP::int,configuration,FIP_type,steering_type,transmission_type,wheel_drive_type +from + mmt_staging2.PTO_report_tractor_specs_block; insert into mmt_ods.test_instance ( @@ -51,7 +49,7 @@ file_format, sheet_mnemonic, make,model from - mmt_staging2.BUDNI_PTO_Spec_H1_block; + mmt_staging2.PTO_report_tractor_specs_block; insert into mmt_ods.test_instance_engine_info ( @@ -71,15 +69,13 @@ function_id, file_syspk, file_format, sheet_mnemonic, -make,model, -rated_rpm::int, -engine_to_pto_ratio -from mmt_staging2.BUDNI_PTO_Spec_H1_block; +make,model,rated_rpm::int,engine_to_pto_ratio +from mmt_staging2.PTO_report_tractor_specs_block; /*block */ -insert into mmt_ods.budni_pto_perf_results_summary +insert into mmt_ods.PTO_Perf_Report_Summary ( client_id, function_id, @@ -93,11 +89,12 @@ pto_sub_category , power_kw, speed_rpm_pto , speed_rpm_engine , -fuel_consumption_lh, -fuel_consumption_kgh, -specific_kg_per_kwh, -specifc_energy_kwhl +fuel_consumption_ltr_per_hr , +fuel_consumption_kg_per_h , +sfc_kg_per_kwh , +specifc_energy_kwh_per_ltr ) + select client_id, function_id, @@ -105,16 +102,15 @@ file_syspk, file_format, sheet_mnemonic, make,model, -column2, -column3, -column4::numeric,column5::numeric,column6::numeric,column7::numeric,column8::numeric, -column9::numeric,column10::numeric -from mmt_staging2.BUDNI_PTO_Perf_Report_block where ods_record=1 +c2, +c3, +c4::numeric,c5::numeric,c6::numeric,c7::numeric,c8::numeric,c9::numeric,c10::numeric +from mmt_staging2.PTOBST_RPT_PTO_performance_report_block where ods_record=1 order by rank; /*block */ -insert into mmt_ods.budni_pto_perf_results_details +insert into mmt_ods.PTO_Perf_Report_Details ( client_id, function_id, @@ -128,7 +124,7 @@ no_load_max_engine_speed_rpm, equi_crankshaft_torque_at_max_power_nm, max_equi_crankshaft_torque_nm, engine_speed_at_max_equi_crankshaft_torque_rpm, -backup_torque, +pct_backup_torque, pct_smoke_level_max_light_absorption_coef_per_mtr, range_of_atm_conditions_temp_c, range_of_atm_conditions_pressure_kpa, @@ -141,18 +137,17 @@ file_syspk, file_format, sheet_mnemonic, make,model, -column3, -column4::int, -column5::numeric, -column6::numeric,column7::int,column8::numeric, -column9::numeric,column10,column11,column12 -from mmt_staging2.BUDNI_PTO_MMTKeyword1_block +c3, +c4::int, +c5::numeric, +c6::numeric,c7::int,c8::numeric, +c9::numeric,c10,c11,c12 +from mmt_staging2.PTOBST_RPT_MMTKeyword1_block where ods_record=1; - /* block */ -insert into mmt_ods.budni_pto_perf_results_details +insert into mmt_ods.PTO_Perf_Report_Details ( client_id, function_id, @@ -172,20 +167,36 @@ pressure_at_max_power_exhst_gas_bfr_turbo_charger_kpa, consumptions_lub_oil_gkwh, consumptions_coolant_water_pct_of_total_coolant_capacity ) + select client_id, function_id, file_syspk, file_format, sheet_mnemonic, make,model, -column3, -column4::numeric,column5::numeric,column6::numeric,column7::numeric,column8::numeric,column9::numeric, -column10,column11::numeric,column12::numeric -from mmt_staging2.BUDNI_PTO_MMTKeyword2_block -where ods_record=1 and column3='Natural Ambient'; +c3, +c4::numeric,c5::numeric,c6::numeric,c7::numeric,c8::numeric,c9::numeric,c10::numeric,c11::numeric,c12::numeric +from mmt_staging2.PTOBST_RPT_MMTKeyword2_block +where ods_record=1 and c3='High Ambient'; -insert into mmt_ods.budni_test_observations -( +update mmt_ods.PTO_Perf_Report_Details a +set +max_temp_engine_oil_c=c4::numeric, +max_temp_coolant_water_c=c5::numeric, +max_temp_fuel_c=c6::numeric, +max_temp_air_intake_c=c7::numeric, +max_temp_exhaust_gas_c=c8::numeric, +pressure_at_max_power_intake_air_kpa=c9::numeric, +pressure_at_max_power_exhst_gas_bfr_turbo_charger_kpa=c10::numeric, +consumptions_lub_oil_gkwh=c11::numeric, +consumptions_coolant_water_pct_of_total_coolant_capacity=c12::numeric +from mmt_staging2.PTOBST_RPT_MMTKeyword2_block b +where a.ambient_type=b.c3 +and a.ambient_type='Natural Ambient' and ods_record=1; + +/* block */ + +insert into mmt_ods.PTO_Perf_Test_Observations( client_id, function_id, test_file_ref_no, @@ -199,21 +210,18 @@ category_evaluative_or_non_evaluative, requirements_as_per_is_12207_2008, values_declared_by_the_applicant_d_rqmt, as_observed, -whether_meets_the_requirements_yesno +whether_meets_the_requirements_yn + ) select client_id, function_id, file_syspk, file_format, sheet_mnemonic, -make,model,column3,column4,column7,column8,column10,column11,column12 -from mmt_staging2.BUDNI_PTO_Summary_block +make,model,c3,c4,c7,c8,c10::numeric,c11::numeric,c12 +from mmt_staging2.PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block where rank in (3,4) and ods_record=1 ; end -$$ LANGUAGE plpgsql; - -select mmt_staging2.fn_BUDNI_PTO_ODS(); - - +$$ LANGUAGE plpgsql; \ No newline at end of file diff --git a/MMT_SQL/ods/ftdry_trs_ods.sql b/MMT_SQL/ods/ftdry_trs_ods.sql deleted file mode 100644 index cb73c36..0000000 --- a/MMT_SQL/ods/ftdry_trs_ods.sql +++ /dev/null @@ -1,178 +0,0 @@ -drop function if exists mmt_staging2.fn_FTDRY_TRS_ODS ; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTDRY_TRS_ODS() - RETURNS void AS $$ - begin - -execute 'insert into mmt_ods.test_instance -( -client_id, -function_id, -test_file_ref_no , -test_report_no, -objective_of_test, -background_of_test, -job_order_no, -test_location_name, -soil_moisture_content_pct, -soil_bulk_density_g_per_cc, -test_engineer, -test_operator, -date_of_test, -test_report_date, -season, -type_of_soil, -soil_cone_index, -field_condition -) -select -client_id,function_id, -file_number, -report_reference_no test_report_no, -objective_of_test, -background_of_test, -job_order_no, -test_location test_location_name, -soil_moisture_content_::int soil_moisture_content_pct , -soil_bulk_density_g_cc::int soil_bulk_density_g_per_cc, -test_engineer, -test_operator, -date_of_test::date, -report_date::date test_report_date, -season, -type_of_soil, -soil_cone_index_kpa::int soil_cone_index, -field_condition -from mmt_staging2.ftdry_trs_h1_block'; - - -exceute 'insert into mmt_ods.test_instance_tractor_info -( -client_id, -function_id, -tractor_model, -tractor_make, -tractor_sr_no, -tractor_engine_hp, -fip_type, -hour_Meter_Reading, -Steering_Type, -Transmission_Type, -wheel_drive_type, -egr_yn, -Brake_Type, -PTO_Type, -Standard_PTO_Speed_RPM, -EPTO_Speed_RPM, -tractor_weight_front_kg, -tractor_weight_rear_kg, -tractor_weight_total_kg, -Ballasted_Tractor_Accessories, -Mechanical_Ballast_Rear, -mechanical_ballast_rear_in_kg, -water_ballast_rear_75_pct , -Mechanical_Ballast_Front, -mechanical_ballast_front_kg , -Total_Ballast_Weight, -test_file_ref_no -) -select -client_id, -function_id, -Tractor_Model, -Tractor_Make, -Tractor_Sr_No, -Tractor_Engine_HP::float, -FIP_Type, -hour_Meter_Reading::int, -Steering_Type, -Transmission_Type, -Wheel_Drive_Type_WD wheel_drive_type , -EGR_Yes_No egr_yn, -Brake_Type , -PTO_Type , -Standard_PTO_Speed_RPM::int, -EPTO_Speed_RPM::int, -Tractor_Weight_kg_Front::int tractor_weight_front_kg , -Tractor_Weight_kg_Rear::int tractor_weight_rear_kg , -Tractor_Weight_kg_Total::int tractor_weight_total_kg , -Ballasted_Tractor_Accessories, -Mechanical_Ballast_Rear, -Mechanical_Ballast_Rear_in_KG::int mechanical_ballast_rear_in_kg , -Water_Ballast_Rear water_ballast_rear_75_pct , -Mechanical_Ballast_Front, -Mechanical_Ballast_Front_in_Kg::int mechanical_ballast_front_kg , -Total_Ballast_Weight::int, -file_number -from mmt_staging2.ftdry_trs_spec_block' - - - -execute 'insert into mmt_ods.test_instance_engine_info -( -client_id, -function_id, -low_idle_observed , -high_idle_observed , -rated_rpm_observed , -engine_to_pto_ratio_540_pto, -engine_to_pto_ratio_540e_pto, -tractor_model, -tractor_make, -test_file_ref_no -) -select -client_id, -function_id, -low_idle::int low_idle_observed , -high_idle::int high_idle_observed , -rated_rpm::int rated_rpm_observed -,engine_to_pto_ratio_540_pto, -engine_to_pto_ratio_540e_pto, -file_number -from mmt_staging2.ftdry_trs_engine_rpm_block -where tractor_model is not null' - - - -execute 'insert into mmt_ods.test_instance_implement_info -( -client_id, -function_id, -name_of_implement, -type_of_implement, -make_of_implement, -no_of_disc_blades_bottoms, -cutting_width_m, -implement_weight_kg, -hitch_category, -span_for_mounted_implement_cm, -mast_height_for_mounted_implement_cm, -test_file_ref_no -) -select -client_id, -function_id, -name_of_implement, -type_of_implement, -make_of_implement, -no_of_bottoms_tyne_disc_blade::int no_of_disc_blades_bottoms, -cutting_width_m, -implement_weight_kg::int, -hitch_category, -span_cm_for_mounted_implement::int span_for_mounted_implement_cm , -mast_height_cm_for_mounted_implement::int mast_height_for_mounted_implement_cm, -file_number -from mmt_staging2.ftdry_trs_implement_block; - - -end -$$ LANGUAGE plpgsql; - -select mmt_staging2.fn_FTDRY_TRS_ODS(); - - - -from mmt_staging2.ftdry_trs_implement_block where name_of_implement is not null; - -end -$$ LANGUAGE plpgsql; diff --git a/MMT_SQL/onetime/create_table_DBOECD-TEST.txt b/MMT_SQL/onetime/create_table_DBOECD-TEST.txt new file mode 100644 index 0000000..b5839da --- /dev/null +++ b/MMT_SQL/onetime/create_table_DBOECD-TEST.txt @@ -0,0 +1,750 @@ +/ create block tables / + +SET search_path TO mmt_staging2; + +drop table if exists mmt_staging2.dboecd_test_transmission_wheels_int; +drop table if exists mmt_staging2.dboecd_test_h1_int; +drop table if exists mmt_staging2.dboecd_test_engine_rpm_engine_to_pto_block; +drop table if exists mmt_staging2.dboecd_test_engine_rpm_required_pull_block; +drop table if exists mmt_staging2.dboecd_test_engine_rpm_weight_block; +drop table if exists mmt_staging2.dboecd_test_engine_rpm_tyre_details_block; +drop table if exists mmt_staging2.dboecd_test_engine_RPM_tyre_details_int; +drop table if exists mmt_staging2.dboecd_test_test_condition_block; +drop table if exists mmt_staging2.dboecd_test_drawbar_performance_selected_summary_block; +drop table if exists mmt_staging2.dboecd_test_drawbar_performance_gear_performance_block; +drop table if exists mmt_staging2.dboecd_test_drawbar_performance_fuel_consumption_block; +drop table if exists mmt_staging2.dboecd_test_test_equipment_used_block; +drop table if exists mmt_staging2.dboecd_test_measurement_uncertainty_block; +drop table if exists mmt_staging2.dboecd_test_tractor_specifications_engine_details_block; +drop table if exists mmt_staging2.dboecd_test_tractor_specifications_cylinders_block; +drop table if exists mmt_staging2.dboecd_test_tractor_specifications_fuel_and_injection_block; +drop table if exists mmt_staging2.dboecd_test_tractor_specifications_cleaner_block; +drop table if exists mmt_staging2.dboecd_test_transmission_clutch_block; +drop table if exists mmt_staging2.dboecd_test_transmission_drawbar_block; +drop table if exists mmt_staging2.dboecd_test_transmission_speed_chart_desc_block; +drop table if exists mmt_staging2.dboecd_test_transmission_wheels_block; +drop table if exists mmt_staging2.dboecd_test_transmission_fuel_lubricant_int; +drop table if exists mmt_staging2.dboecd_test_remarks_block; +drop table if exists mmt_staging2.dboecd_test_remarks_footer_block; +drop table if exists mmt_staging2.dboecd_test_h1_block; +drop table if exists mmt_staging2.dboecd_test_transmission_fuel_lubricant_block; +drop table if exists mmt_staging2.dboecd_test_engine_rpm_rpm_block; +drop table if exists mmt_staging2.dboecd_test_transmission_speed_chart_block; +drop table if exists mmt_staging2.stg_specific_table_dboecd_test; +drop table if exists mmt_staging2.stg_process_table_dboecd_test; + +create table mmt_staging2.DBOECD_TEST_H1_INT +(syspk serial, +dummy_f text, +file_syspk int, +client_id int, +function_id int, +make text, +model text, +file_format text, +sheet_mnemonic text, +c1 text, +c2 text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_TEST_H1_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +Test_Request_no text, +Sample_Receipt_Date text, +Test_report_No text, +Tractor_Model text, +Generation text, +Customer_Name text, +Test_Engineer text, +Test_Report_Date text, +No_of_Sample text, +Test_Start_Date text, +Test_End_Date text, +Tractor_Sr_No text, +Test_Standard_Refer text, +Test_Location text, +Operator_Name text, +Project_Group text, +Objective text, +Acceptance_criteria text, +rank number, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.DBOECD_test_engine_RPM_RPM_block +(syspk serial,dummy_f text,file_syspk int,client_id int,function_id int,make text,model text,file_format text,sheet_mnemonic text,low_idle_declared text,high_idle_declared text,low_idle_observed text,high_idle_observed text,create_time timestamp DEFAULT current_timestamp); + +create table mmt_staging2.DBOECD_test_engine_RPM_engine_to_PTO_block(syspk serial,dummy_f text,file_syspk int,client_id int,function_id int,make text,model text, file_format text,sheet_mnemonic text,rated_speed text,engine_to_PTO_ratio text, wheel_base_mm text,engine_power_hp text,PTO_Power_hp text,create_time timestamp DEFAULT current_timestamp); + +create table mmt_staging2.DBOECD_test_engine_RPM_required_pull_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +pull_type text, +required_pull_in_kg text, +required_power_in_hp text, +actual_pull_in_kg text, +actual_power_in_hp text, +calculated_hitch_height_mm text, +actual_hitch_height_mm text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_engine_RPM_weight_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +weight_kg text, +Front text, +rear text, +Total text, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.DBOECD_test_engine_RPM_tyre_details_int +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +s_no text, +tyre_details text, +front text, +rear text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_engine_RPM_tyre_details_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +model text, +Make text, +file_format text, +sheet_mnemonic text, +tyre_make text, +size text, +Ply_Rating text, +Load_Carrying_Capacity_in_Kg text, +Pressure_kg_cm2 text, +Number_of_lug text, +Number_of_no_load_lug_30m text, +Lug_Height text, +Dynamic_rolling_radius_mm text, +Wheel_Rim_Make_Size text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_test_condition_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +c1 text, +c2 text, +c3 text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_drawbar_performance_selected_summary_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +c1 text , +c2 text , +c3 text , +c4 text , +c5 text , +c6 text , +c7 text , +c8 text , +c9 text , +c10 text , +c11 text , +c12 text , +c13 text , +c14 text , +c15 text , +c16 text , +c17 text , +c18 text , +c19 text , +c20 text , +c21 text , +c22 text , +c23 text , +c24 text , +c25 text , +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_drawbar_performance_gear_performance_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +c1 text , +c2 text , +c3 text , +c4 text , +c5 text , +c6 text , +c7 text , +c8 text , +c9 text , +c10 text , +c11 text , +c12 text , +c13 text , +c14 text , +c15 text , +c16 text , +c17 text , +c18 text , +c19 text , +c20 text , +c21 text , +c22 text , +c23 text , +c24 text , +c25 text , +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_drawbar_performance_fuel_consumption_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +c1_1 text, +c2_1 text, +c1 text , +c2 text , +c3 text , +c4 text , +c5 text , +c6 text , +c7 text , +c8 text , +c9 text , +c10 text , +c11 text , +c12 text , +c13 text , +c14 text , +c15 text , +c16 text , +c17 text , +c18 text , +c19 text , +c20 text , +c21 text , +c22 text , +c23 text , +c24 text , +c25 text , +Remark text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_test_equipment_used_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +s_no text, +instruments text, +instruments_no text, +cali_due_date text, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.DBOECD_test_measurement_uncertainty_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +load_cell text, +rpm_meter text, +speed text, +fuel_flow_meter text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make_in_block text, +type text, +model_in_block text, +serial_no text, +E_P_Ratio text, +rated_speed text, +high_idle text, +low_Idle text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_tractor_specifications_cylinders_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +number text, +stroke text, +bore text, +capacity text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +capacity_of_fuel_tank_lit text, +make_type_and_model_of_injection_pump text, +manufacturer_production_setting text, +make_type_and_model_of_injectors text, +make_type_and_model_of_magneto_coil_and_distributor text, +make_type_and_model_of_carburetor text, +ignition_or_injection_timing_Manual_or_automatic text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_tractor_specifications_cleaner_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +make text, +model text, +file_format text, +sheet_mnemonic text, +cleaner_type text, +make_and_model text, +type text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_transmission_clutch_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +clutch_type text, +steering_type text, +diameter_of_disc_mm text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_transmission_drawbar_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +Type text, +Height_above_ground_max_mm text , +Height_above_ground_min_mm text, +Position_related_to_PTO text, +Wheel_Base text, +test_condition text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_transmission_speed_chart_desc_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +descr text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_transmission_speed_chart_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +tyre_condition text, +gear text, +forward text, +reverse text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_transmission_wheels_int +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +Descriptions text, +Steered_wheels text, +Driving_wheel text, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.DBOECD_test_transmission_wheels_block + ( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +Make_of_tyres text, +Types text, +Size text, +Maximum_permissible_load_kg text, +Ply_rating text, +Track_width_max_mm text, +Track_width_min_mm text, +Inflation_pressure_kg_cm2 text, +Location_of_driving_wheel text, +create_time timestamp DEFAULT current_timestamp + ); + + +create table mmt_staging2.DBOECD_test_transmission_fuel_lubricant_int +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +Descriptions text, +Diesel_BS_IV text, +Engine_oil text, +Transmission_oil text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_transmission_fuel_lubricant_block + ( +syspk serial, +client_id int, +function_id int, +dummy_f text, +file_syspk int, +make text, +model text, +file_format text, +sheet_mnemonic text, + Trade_name text, +type text, +Octane_Cetane_number text, +Viscosity text, +Density_at_15C text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_remarks_block +( +syspk serial, +client_id int, +function_id int, +dummy_f text, +file_syspk int, +make text, +model text, +file_format text, +sheet_mnemonic text, +remarks text, +parameter text, +acceptance_criteria text, +observations text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBOECD_test_remarks_footer_block +( +syspk serial, +client_id int, +function_id int, +dummy_f text, +file_syspk int, +make text, +model text, +file_format text, +sheet_mnemonic text, +prepared_by text, +approved_by text, +date text, +replaces text, +revision_no text, +comments text, +rev1 text, +rev2 text, +rev3 text, +create_time timestamp DEFAULT current_timestamp +); + +create TABLE mmt_staging2.stg_process_table_dboecd_test ( + generic_syspk int, + file_syspk bigint, + file_name varchar(1024) NULL, + file_date date NULL, + file_format varchar(1024) NULL, + sheet_number int4 NULL, + sheet_name varchar(1024) NULL, + sheet_format text, + sheet_mnemonic varchar(1024) NULL, + row_number int4 NULL, + file_creation_date timestamp NULL, + column1 varchar(1024) NULL, + column2 varchar(1024) NULL, + column3 varchar(1024) NULL, + column4 varchar(1024) NULL, + column5 varchar(1024) NULL, + column6 varchar(1024) NULL, + column7 varchar(1024) NULL, + column8 varchar(1024) NULL, + column9 varchar(1024) NULL, + column10 varchar(1024) NULL, + column11 varchar(1024) NULL, + column12 varchar(1024) NULL, + column13 varchar(1024) NULL, + column14 varchar(1024) NULL, + column15 varchar(1024) NULL, + column16 varchar(1024) NULL, + column17 varchar(1024) NULL, + column18 varchar(1024) NULL, + column19 varchar(1024) NULL, + column20 varchar(1024) NULL, + column21 varchar(1024) NULL, + column22 varchar(1024) NULL, + column23 varchar(1024) NULL, + column24 varchar(1024) NULL, + column25 varchar(1024) NULL, + column26 varchar(1024) NULL, + column27 varchar(1024) NULL, + column28 varchar(1024) NULL, + column29 varchar(1024) NULL, + column30 varchar(1024) NULL, + column31 varchar(1024) NULL, + column32 varchar(1024) NULL, + column33 varchar(1024) NULL, + column34 varchar(1024) NULL, + column35 varchar(1024) NULL, + column36 varchar(1024) NULL, + column37 varchar(1024) NULL, + column38 varchar(1024) NULL, + column39 varchar(1024) NULL, + column40 varchar(1024) NULL, + column41 varchar(1024) NULL, + column42 varchar(1024) NULL, + column43 varchar(1024) NULL, + column44 varchar(1024) NULL, + column45 varchar(1024) NULL, + column46 varchar(1024) NULL, + column47 varchar(1024) NULL, + column48 varchar(1024) NULL, + column49 varchar(1024) NULL, + column50 varchar(1024) NULL, + column51 varchar(1024) NULL, + column52 varchar(1024) NULL, + column53 varchar(1024) NULL, + is_rownumber_fetched int4 NULL, + create_time timestamp DEFAULT current_timestamp, + rank int4 NULL, + rank_tag text null +); + + +CREATE TABLE mmt_staging2.stg_specific_table_dboecd_test ( + generic_syspk int, + file_syspk bigint, + file_name varchar(1024) NULL, + file_date date NULL, + file_format varchar(1024) NULL, + sheet_number int4 NULL, + sheet_name varchar(1024) NULL, + sheet_format text, + sheet_mnemonic varchar(1024) NULL, + row_number int4 NULL, + file_creation_date timestamp NULL, + column1 varchar(1024) NULL, + column2 varchar(1024) NULL, + column3 varchar(1024) NULL, + column4 varchar(1024) NULL, + column5 varchar(1024) NULL, + column6 varchar(1024) NULL, + column7 varchar(1024) NULL, + column8 varchar(1024) NULL, + column9 varchar(1024) NULL, + column10 varchar(1024) NULL, + column11 varchar(1024) NULL, + column12 varchar(1024) NULL, + column13 varchar(1024) NULL, + column14 varchar(1024) NULL, + column15 varchar(1024) NULL, + column16 varchar(1024) NULL, + column17 varchar(1024) NULL, + column18 varchar(1024) NULL, + column19 varchar(1024) NULL, + column20 varchar(1024) NULL, + column21 varchar(1024) NULL, + column22 varchar(1024) NULL, + column23 varchar(1024) NULL, + column24 varchar(1024) NULL, + column25 varchar(1024) NULL, + column26 varchar(1024) NULL, + column27 varchar(1024) NULL, + column28 varchar(1024) NULL, + column29 varchar(1024) NULL, + column30 varchar(1024) NULL, + column31 varchar(1024) NULL, + column32 varchar(1024) NULL, + column33 varchar(1024) NULL, + column34 varchar(1024) NULL, + column35 varchar(1024) NULL, + column36 varchar(1024) NULL, + column37 varchar(1024) NULL, + column38 varchar(1024) NULL, + column39 varchar(1024) NULL, + column40 varchar(1024) NULL, + column41 varchar(1024) NULL, + column42 varchar(1024) NULL, + column43 varchar(1024) NULL, + column44 varchar(1024) NULL, + column45 varchar(1024) NULL, + column46 varchar(1024) NULL, + column47 varchar(1024) NULL, + column48 varchar(1024) NULL, + column49 varchar(1024) NULL, + column50 varchar(1024) NULL, + column51 varchar(1024) NULL, + column52 varchar(1024) NULL, + column53 varchar(1024) NULL, + is_rownumber_fetched int4 null, + create_time timestamp DEFAULT current_timestamp +); \ No newline at end of file diff --git a/MMT_SQL/onetime/create_table_DBSTD_TEST.txt b/MMT_SQL/onetime/create_table_DBSTD_TEST.txt new file mode 100644 index 0000000..81de318 --- /dev/null +++ b/MMT_SQL/onetime/create_table_DBSTD_TEST.txt @@ -0,0 +1,695 @@ +/* create block tables */ + +SET search_path TO mmt_staging2; + +drop table if exists mmt_staging2.dbstd_test_transmission_wheels_int; +drop table if exists mmt_staging2.dbstd_test_h1_int; +drop table if exists mmt_staging2.dbstd_test_engine_rpm_engine_to_pto_block; +drop table if exists mmt_staging2.dbstd_test_engine_rpm_required_pull_block; +drop table if exists mmt_staging2.dbstd_test_engine_rpm_weight_block; +drop table if exists mmt_staging2.dbstd_test_engine_rpm_tyre_details_block; +drop table if exists mmt_staging2.DBSTD_test_engine_RPM_tyre_details_int; +drop table if exists mmt_staging2.dbstd_test_test_condition_block; +drop table if exists mmt_staging2.dbstd_test_drawbar_performance_selected_summary_block; +drop table if exists mmt_staging2.dbstd_test_drawbar_performance_gear_performance_block; +drop table if exists mmt_staging2.dbstd_test_test_equipment_used_block; +drop table if exists mmt_staging2.dbstd_test_measurement_uncertainty_block; +drop table if exists mmt_staging2.dbstd_test_tractor_specifications_engine_details_block; +drop table if exists mmt_staging2.dbstd_test_tractor_specifications_cylinders_block; +drop table if exists mmt_staging2.dbstd_test_tractor_specifications_fuel_and_injection_block; +drop table if exists mmt_staging2.dbstd_test_tractor_specifications_cleaner_block; +drop table if exists mmt_staging2.dbstd_test_transmission_clutch_block; +drop table if exists mmt_staging2.dbstd_test_transmission_drawbar_block; +drop table if exists mmt_staging2.dbstd_test_transmission_speed_chart_desc_block; +drop table if exists mmt_staging2.dbstd_test_transmission_wheels_block; +drop table if exists mmt_staging2.dbstd_test_transmission_fuel_lubricant_int; +drop table if exists mmt_staging2.dbstd_test_remarks_block; +drop table if exists mmt_staging2.dbstd_test_remarks_footer_block; +drop table if exists mmt_staging2.dbstd_test_h1_block; +drop table if exists mmt_staging2.dbstd_test_transmission_fuel_lubricant_block; +drop table if exists mmt_staging2.dbstd_test_engine_rpm_rpm_block; +drop table if exists mmt_staging2.dbstd_test_transmission_speed_chart_block; +drop table if exists mmt_staging2.stg_specific_table_dbstd_test; +drop table if exists mmt_staging2.stg_process_table_dbstd_test; + +create table mmt_staging2.DBSTD_TEST_H1_INT (syspk serial,dummy_f text,file_syspk int,client_id int,function_id int,make text,model text,file_format text,sheet_mnemonic text,c1 text,c2 text); + +create table mmt_staging2.DBSTD_TEST_H1_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +Test_Request_no text, +Sample_Receipt_Date text, +Test_report_No text, +Tractor_Model text, +Generation text, +Customer_Name text, +Test_Engineer text, +Test_Report_Date text, +No_of_Sample text, +Test_Start_Date text, +Test_End_Date text, +Tractor_Sr_No text, +Test_Standard_Refer text, +Test_Location text, +Operator_Name text, +Project_Group text, +Objective text, +Acceptance_criteria text, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.DBSTD_test_engine_RPM_RPM_block +(syspk serial,dummy_f text,file_syspk int,client_id int,function_id int,make text,model text,file_format text,sheet_mnemonic text,low_idle_declared text,high_idle_declared text,low_idle_observed text,high_idle_observed text,create_time timestamp DEFAULT current_timestamp); + +create table mmt_staging2.DBSTD_test_engine_RPM_engine_to_PTO_block(syspk serial,dummy_f text,file_syspk int,client_id int,function_id int,make text,model text, file_format text,sheet_mnemonic text,rated_speed text,engine_to_PTO_ratio text, wheel_base_mm text,engine_power_hp text,PTO_Power_hp text,create_time timestamp DEFAULT current_timestamp); + +create table mmt_staging2.DBSTD_test_engine_RPM_required_pull_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +pull_type text, +required_pull_in_kg text, +required_power_in_hp text, +actual_pull_in_kg text, +actual_power_in_hp text, +calculated_hitch_height_mm text, +actual_hitch_height_mm text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_engine_RPM_weight_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +weight_kg text, +Front text, +rear text, +Total text, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.DBSTD_test_engine_RPM_tyre_details_int +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +s_no text, +tyre_details text, +front text, +rear text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_engine_RPM_tyre_details_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +model text, +Make text, +file_format text, +sheet_mnemonic text, +tyre_make text, +size text, +Ply_Rating text, +Load_Carrying_Capacity_in_Kg text, +Pressure_kg_cm2 text, +Number_of_lug text, +Number_of_no_load_lug_30m text, +Lug_Height text, +Dynamic_rolling_radius_mm text, +Wheel_Rim_Make_Size text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_test_condition_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +c1 text, +c2 text, +c3 text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_drawbar_performance_selected_summary_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +c1 text , +c2 text , +c3 text , +c4 text , +c5 text , +c6 text , +c7 text , +c8 text , +c9 text , +c10 text , +c11 text , +c12 text , +c13 text , +c14 text , +c15 text , +c16 text , +c17 text , +c18 text , +c19 text , +c20 text , +c21 text , +c22 text , +c23 text , +c24 text , +c25 text , +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_drawbar_performance_gear_performance_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +c1 text , +c2 text , +c3 text , +c4 text , +c5 text , +c6 text , +c7 text , +c8 text , +c9 text , +c10 text , +c11 text , +c12 text , +c13 text , +c14 text , +c15 text , +c16 text , +c17 text , +c18 text , +c19 text , +c20 text , +c21 text , +c22 text , +c23 text , +c24 text , +c25 text , +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_test_equipment_used_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +s_no text, +instruments text, +instruments_no text, +cali_due_date text, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.DBSTD_test_measurement_uncertainty_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +load_cell text, +rpm_meter text, +speed text, +fuel_flow_meter text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_tractor_specifications_engine_details_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make_in_block text, +type text, +model_in_block text, +serial_no text, +E_P_Ratio text, +rated_speed text, +high_idle text, +low_Idle text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_tractor_specifications_cylinders_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +number text, +stroke text, +bore text, +capacity text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_tractor_specifications_fuel_and_injection_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +capacity_of_fuel_tank_lit text, +make_type_and_model_of_injection_pump text, +manufacturer_production_setting text, +make_type_and_model_of_injectors text, +make_type_and_model_of_magneto_coil_and_distributor text, +make_type_and_model_of_carburetor text, +ignition_or_injection_timing_Manual_or_automatic text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_tractor_specifications_cleaner_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +make text, +model text, +file_format text, +sheet_mnemonic text, +cleaner_type text, +make_and_model text, +type text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_transmission_clutch_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +clutch_type text, +steering_type text, +diameter_of_disc_mm text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_transmission_drawbar_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +Type text, +Height_above_ground_max_mm text , +Height_above_ground_min_mm text, +Position_related_to_PTO text, +Wheel_Base text, +test_condition text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_transmission_speed_chart_desc_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +descr text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_transmission_speed_chart_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +tyre_condition text, +gear text, +forward text, +reverse text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.dbstd_test_transmission_wheels_int +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +Descriptions text, +Steered_wheels text, +Driving_wheel text, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.dbstd_test_transmission_wheels_block + ( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +Make_of_tyres text, +Types text, +Size text, +Maximum_permissible_load_kg text, +Ply_rating text, +Track_width_max_mm text, +Track_width_min_mm text, +Inflation_pressure_kg_cm2 text, +Location_of_driving_wheel text + ); + + +create table mmt_staging2.DBSTD_test_transmission_fuel_lubricant_int +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +make text, +model text, +file_format text, +sheet_mnemonic text, +Descriptions text, +Diesel_BS_IV text, +Engine_oil text, +Transmission_oil text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_transmission_fuel_lubricant_block + ( +syspk serial, +client_id int, +function_id int, +dummy_f text, +file_syspk int, +make text, +model text, +file_format text, +sheet_mnemonic text, + Trade_name text, +type text, +Octane_Cetane_number text, +Viscosity text, +Density_at_15C text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_remarks_block +( +syspk serial, +client_id int, +function_id int, +dummy_f text, +file_syspk int, +make text, +model text, +file_format text, +sheet_mnemonic text, +remarks text, +parameter text, +acceptance_criteria text, +observations text, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.DBSTD_test_remarks_footer_block +( +syspk serial, +client_id int, +function_id int, +dummy_f text, +file_syspk int, +make text, +model text, +file_format text, +sheet_mnemonic text, +prepared_by text, +reviewed_by text, +approved_by text, +date text, +replaces text, +revision_no text, +comments text, +rev1 text, +rev2 text, +rev3 text, +create_time timestamp DEFAULT current_timestamp +); + + +create TABLE mmt_staging2.stg_process_table_dbstd_test ( + generic_syspk int, + file_syspk bigint, + file_name varchar(1024) NULL, + file_date date NULL, + file_format varchar(1024) NULL, + sheet_number int4 NULL, + sheet_name varchar(1024) NULL, + sheet_format text, + sheet_mnemonic varchar(1024) NULL, + row_number int4 NULL, + file_creation_date timestamp NULL, + column1 varchar(1024) NULL, + column2 varchar(1024) NULL, + column3 varchar(1024) NULL, + column4 varchar(1024) NULL, + column5 varchar(1024) NULL, + column6 varchar(1024) NULL, + column7 varchar(1024) NULL, + column8 varchar(1024) NULL, + column9 varchar(1024) NULL, + column10 varchar(1024) NULL, + column11 varchar(1024) NULL, + column12 varchar(1024) NULL, + column13 varchar(1024) NULL, + column14 varchar(1024) NULL, + column15 varchar(1024) NULL, + column16 varchar(1024) NULL, + column17 varchar(1024) NULL, + column18 varchar(1024) NULL, + column19 varchar(1024) NULL, + column20 varchar(1024) NULL, + column21 varchar(1024) NULL, + column22 varchar(1024) NULL, + column23 varchar(1024) NULL, + column24 varchar(1024) NULL, + column25 varchar(1024) NULL, + column26 varchar(1024) NULL, + column27 varchar(1024) NULL, + column28 varchar(1024) NULL, + column29 varchar(1024) NULL, + column30 varchar(1024) NULL, + column31 varchar(1024) NULL, + column32 varchar(1024) NULL, + column33 varchar(1024) NULL, + column34 varchar(1024) NULL, + column35 varchar(1024) NULL, + column36 varchar(1024) NULL, + column37 varchar(1024) NULL, + column38 varchar(1024) NULL, + column39 varchar(1024) NULL, + column40 varchar(1024) NULL, + column41 varchar(1024) NULL, + column42 varchar(1024) NULL, + column43 varchar(1024) NULL, + column44 varchar(1024) NULL, + column45 varchar(1024) NULL, + column46 varchar(1024) NULL, + column47 varchar(1024) NULL, + column48 varchar(1024) NULL, + column49 varchar(1024) NULL, + column50 varchar(1024) NULL, + column51 varchar(1024) NULL, + column52 varchar(1024) NULL, + column53 varchar(1024) NULL, + is_rownumber_fetched int4 NULL, + create_time timestamp DEFAULT current_timestamp, + rank int4 NULL, + rank_tag text null +); + + + +CREATE TABLE mmt_staging2.stg_specific_table_dbstd_test ( + generic_syspk int, + file_syspk bigint, + file_name varchar(1024) NULL, + file_date date NULL, + file_format varchar(1024) NULL, + sheet_number int4 NULL, + sheet_name varchar(1024) NULL, + sheet_format text, + sheet_mnemonic varchar(1024) NULL, + row_number int4 NULL, + file_creation_date timestamp NULL, + column1 varchar(1024) NULL, + column2 varchar(1024) NULL, + column3 varchar(1024) NULL, + column4 varchar(1024) NULL, + column5 varchar(1024) NULL, + column6 varchar(1024) NULL, + column7 varchar(1024) NULL, + column8 varchar(1024) NULL, + column9 varchar(1024) NULL, + column10 varchar(1024) NULL, + column11 varchar(1024) NULL, + column12 varchar(1024) NULL, + column13 varchar(1024) NULL, + column14 varchar(1024) NULL, + column15 varchar(1024) NULL, + column16 varchar(1024) NULL, + column17 varchar(1024) NULL, + column18 varchar(1024) NULL, + column19 varchar(1024) NULL, + column20 varchar(1024) NULL, + column21 varchar(1024) NULL, + column22 varchar(1024) NULL, + column23 varchar(1024) NULL, + column24 varchar(1024) NULL, + column25 varchar(1024) NULL, + column26 varchar(1024) NULL, + column27 varchar(1024) NULL, + column28 varchar(1024) NULL, + column29 varchar(1024) NULL, + column30 varchar(1024) NULL, + column31 varchar(1024) NULL, + column32 varchar(1024) NULL, + column33 varchar(1024) NULL, + column34 varchar(1024) NULL, + column35 varchar(1024) NULL, + column36 varchar(1024) NULL, + column37 varchar(1024) NULL, + column38 varchar(1024) NULL, + column39 varchar(1024) NULL, + column40 varchar(1024) NULL, + column41 varchar(1024) NULL, + column42 varchar(1024) NULL, + column43 varchar(1024) NULL, + column44 varchar(1024) NULL, + column45 varchar(1024) NULL, + column46 varchar(1024) NULL, + column47 varchar(1024) NULL, + column48 varchar(1024) NULL, + column49 varchar(1024) NULL, + column50 varchar(1024) NULL, + column51 varchar(1024) NULL, + column52 varchar(1024) NULL, + column53 varchar(1024) NULL, + is_rownumber_fetched int4 null, + create_time timestamp DEFAULT current_timestamp +); diff --git a/MMT_SQL/onetime/create_tables_BUDNI_ARC.txt b/MMT_SQL/onetime/create_tables_BUDNI_ARC.txt new file mode 100644 index 0000000..f48f75f --- /dev/null +++ b/MMT_SQL/onetime/create_tables_BUDNI_ARC.txt @@ -0,0 +1,223 @@ +drop table if exists mmt_staging2.BUDNI_ARC_Spec_H1_Block; +drop table if exists mmt_staging2.BUDNI_ARC_Perf_Atmos_Meas_Test_Block; +drop table if exists mmt_staging2.BUDNI_ARC_Test_Obs_Summary_Block; +drop table if exists mmt_staging2.stg_process_table_BUDNI_ARC; +drop table if exists mmt_staging2.stg_specific_table_BUDNI_ARC; + +create table mmt_staging2.BUDNI_ARC_Spec_H1_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +tractor_HP text, +rated_rpm text, +configuration text, +transmission_type text, +wheel_drive_type text, +FIP_type text, +steering_type text, +Engine_to_PTO_ratio text, +Ballast_Condition text, +Test_Engine_Set_RPM text, +Type_of_track text , +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.BUDNI_ARC_Perf_Atmos_Meas_Test_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +Temperature_C text, +Pressure_kPa text, +Relative_humidity text, +Mass_of_oil_before_test text, +Position_of_tractor text, +Loss_of_oil text, +Oil_pull_Over text, +Engine_oil_pressure text, +ods_record int default 1, +rank int,create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.BUDNI_ARC_Test_Obs_Summary_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create TABLE mmt_staging2.stg_process_table_BUDNI_ARC ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 NULL, +create_time timestamp DEFAULT current_timestamp, +rank int4 NULL, +rank_tag text null +); + + +CREATE TABLE mmt_staging2.stg_specific_table_BUDNI_ARC ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 null, +create_time timestamp DEFAULT current_timestamp +); + + diff --git a/MMT_SQL/onetime/create_tables_budni_dbp.sql b/MMT_SQL/onetime/create_tables_BUDNI_DBP.txt similarity index 97% rename from MMT_SQL/onetime/create_tables_budni_dbp.sql rename to MMT_SQL/onetime/create_tables_BUDNI_DBP.txt index 3af1e54..1ab7659 100644 --- a/MMT_SQL/onetime/create_tables_budni_dbp.sql +++ b/MMT_SQL/onetime/create_tables_BUDNI_DBP.txt @@ -28,7 +28,8 @@ column13 text, column14 text, column15 text, ods_record int default 1, -rank int +rank int, +create_time timestamp DEFAULT current_timestamp ); create table mmt_staging2.BUDNI_DBP_Drawbar_Perf_Block @@ -61,7 +62,8 @@ column17 text, column18 text, column19 text, ods_record int default 1, -rank int +rank int, +create_time timestamp DEFAULT current_timestamp ); diff --git a/MMT_SQL/onetime/create_tables_BUDNI_FLD.txt b/MMT_SQL/onetime/create_tables_BUDNI_FLD.txt new file mode 100644 index 0000000..3189664 --- /dev/null +++ b/MMT_SQL/onetime/create_tables_BUDNI_FLD.txt @@ -0,0 +1,333 @@ +drop table if exists mmt_staging2.BUDNI_FLD_Spec_H1_Block; +drop table if exists mmt_staging2.BUDNI_FLD_Impl_Test_Int; +drop table if exists mmt_staging2.BUDNI_FLD_Impl_Test_Block; +drop table if exists mmt_staging2.BUDNI_FLD_Cage_Wheel_Block; +drop table if exists mmt_staging2.BUDNI_FLD_Sum_Perf_Test_Int; +drop table if exists mmt_staging2.BUDNI_FLD_Sum_Perf_Test_Block; +drop table if exists mmt_staging2.BUDNI_FLD_Test_Obs_Summary_Block; +drop table if exists mmt_staging2.stg_process_table_BUDNI_FLD; +drop table if exists mmt_staging2.stg_specific_table_BUDNI_FLD; + + +create table mmt_staging2.BUDNI_FLD_Spec_H1_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +tractor_HP text, +rated_rpm text, +configuration text, +transmission_type text, +wheel_drive_type text, +FIP_type text, +steering_type text, +Engine_to_PTO_ratio text, +Ballast_Condition text, +Test_Engine_Set_RPM text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.BUDNI_FLD_Impl_Test_INT +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.BUDNI_FLD_Impl_Test_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +items text, +Make text, +type text, +No_of_Disc_blades text, +Type_of_Disc_blades text, +Size_of_bottoms_blades_1_mm text, +Size_of_bottoms_blades_2_mm text, +Size_of_bottoms_blades_3_mm text, +Spacing_of_bottoms_flanges_mm text, +Lower_hitch_point_span_mm text, +Mast_height_mm text, +Overall_dimensions_mm text, +Overall_dimensions_mm_length text, +Overall_dimensions_mm_Width text, +Overall_dimensions_mm_Height text, +Gross_mass_kg text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.BUDNI_FLD_Cage_Wheel_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Items text, +type text, +Dia_mm text, +Width_mm text, +No_and_types_of_lugs text, +Size_of_angle_section_1_mm text, +Size_of_angle_section_2_mm text, +Size_of_angle_section_3_mm text, +Length_of_lugs_mm text, +Spacing_of_lugs_mm text, +Weight_of_each_cage_wheels_kg text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.BUDNI_FLD_Sum_Perf_Test_Int +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.BUDNI_FLD_Sum_Perf_Test_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +Parameter_operation text, +Type_of_soil text, +Av_soil_moisture_Av_depth_of_standing_water_cm text, +Bulk_density_of_soil_g_cc text, +Cone_index_kgf_sq_cm_Puddling_index text, +Gear_used text, +Av_speed_of_operation_kmph text, +Av_wheel_slip_Av_Travel_reduction text, +Av_depth_of_cut_cm_Av_Depth_of_puddle_cm text, +Av_working_width_cm text, +Area_covered_ha_h text, +Fuel_consumption text, +Fuel_consumption_l_h text, +Fuel_consumption_l_ha text, +Av_draft_of_implement_kN text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.BUDNI_FLD_Test_Obs_Summary_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + + +create TABLE mmt_staging2.stg_process_table_BUDNI_FLD ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 NULL, +create_time timestamp DEFAULT current_timestamp, +rank int4 NULL, +rank_tag text null +); + + +CREATE TABLE mmt_staging2.stg_specific_table_BUDNI_FLD ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 null, +create_time timestamp DEFAULT current_timestamp +); + + diff --git a/MMT_SQL/onetime/create_tables_BUDNI_HDL.txt b/MMT_SQL/onetime/create_tables_BUDNI_HDL.txt new file mode 100644 index 0000000..c2421bf --- /dev/null +++ b/MMT_SQL/onetime/create_tables_BUDNI_HDL.txt @@ -0,0 +1,302 @@ +drop table if exists mmt_staging2.stg_specific_table_budni_hdl; +drop table if exists mmt_staging2.stg_process_table_budni_hdl; +drop table if exists mmt_staging2.budni_hdl_Spec_H1_Block; +drop table if exists mmt_staging2.budni_hdl_power_test_Block; +drop table if exists mmt_staging2.budni_hdl_Lifting_Capacity_Test_Block; +drop table if exists mmt_staging2.budni_hdl_Maintenance_of_lift_load_int; +drop table if exists mmt_staging2.budni_hdl_Maintenance_of_lift_load_Block; +drop table if exists mmt_staging2.budni_hdl_Test_Obs_Summary_Block; + + +create table mmt_staging2.budni_hdl_Spec_H1_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +tractor_make text, +tractor_model text, +tractor_HP text, +rated_rpm text, +hydraulic_type text, +Pump_speed_at_rated_engine_speed_rpm text, +Steering_Type text, +Oil text, +Lift_Rod_type_LH text, +Lift_Rod_type_RH text, +Lift_Rod_Length_LH text, +Lift_Rod_Length_RH text, +Lower_link_Length_LH text, +Lower_link_Length_RH text, +Pump_HP text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.budni_hdl_power_test_block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +Pump_delivery_rate_at_minimum_pressure_and_rated_engine_speed_l_min text, +Maximum_hydraulic_power_kW text, + Pump_delivery_rate_at_maximum_hydraulic_power_l_min text, + Pressure_at_maximum_hydraulic_power_MPa text, + Sustained_pressure_of_the_open_relief_valve_MPa text, +tapping_point_relief_valve_test text, +tapping_point_Pump_performance_test text, +tapping_point_Temperature_of_hydraulic_fluid_C text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.budni_hdl_Lifting_Capacity_Test_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +column10 text, +column11 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.budni_hdl_Maintenance_of_lift_load_int +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column2 text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +column10 text, +column11 text, +column12 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.budni_hdl_Maintenance_of_lift_load_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +Force_applied_at_the_frame_kN text, +Temperature_of_hydraulic_fluid_at_the_start_of_test_C text, +Elapsed_time_minute text, +Cumulative_drop_in_height_of_lift_mm text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.budni_hdl_Test_Obs_Summary_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column2 text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +column10 text, +column11 text, +column12 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create TABLE mmt_staging2.stg_process_table_budni_hdl ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 NULL, +create_time timestamp DEFAULT current_timestamp, +rank int4 NULL, +rank_tag text null +); + + +CREATE TABLE mmt_staging2.stg_specific_table_budni_hdl ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 null, +create_time timestamp DEFAULT current_timestamp +); + + diff --git a/MMT_SQL/onetime/create_tables_BUDNI_HLG.txt b/MMT_SQL/onetime/create_tables_BUDNI_HLG.txt new file mode 100644 index 0000000..431be6a --- /dev/null +++ b/MMT_SQL/onetime/create_tables_BUDNI_HLG.txt @@ -0,0 +1,249 @@ +drop table if exists mmt_staging2.BUDNI_HLG_Spec_H1_Block; +drop table if exists mmt_staging2.BUDNI_HLG_Perf_Test_int; +drop table if exists mmt_staging2.BUDNI_HLG_Perf_Test_block; +drop table if exists mmt_staging2.BUDNI_HLG_Test_Obs_Summary_Block; +drop table if exists mmt_staging2.stg_process_table_BUDNI_HLG; +drop table if exists mmt_staging2.stg_specific_table_BUDNI_HLG; + + +create table mmt_staging2.BUDNI_HLG_Spec_H1_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +tractor_HP text, +rated_rpm text, +configuration text, +transmission_type text, +wheel_drive_type text, +FIP_type text, +steering_type text, +Engine_to_PTO_ratio text, +Ballast_Condition text, +Test_Engine_Set_RPM text, +Type_of_track text , +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.BUDNI_HLG_Perf_Test_int +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column3 text, +column6 text, +column8 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.BUDNI_HLG_Perf_Test_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +type_of_trailer text, +Gross_mass_of_trailer_tonne text, +Height_of_trailer_hitch_above_ground_level_mm text, +Gear_used_during_the_test_for_negotiating_slopes_up_to_8 text, +Average_travel_speed_kmph text, +Average_fuel_consumption text, +l_h text, +ml_km_tonne text, +Average_distance_traveled_per_litre_of_fuel_consumption_km text, +General_observations text, +Effectiveness_of_brakes text, +Maneuverability_of_tractor_trailer_combination text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.BUDNI_HLG_Test_Obs_Summary_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create TABLE mmt_staging2.stg_process_table_BUDNI_HLG ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 NULL, +create_time timestamp DEFAULT current_timestamp, +rank int4 NULL, +rank_tag text null +); + + +CREATE TABLE mmt_staging2.stg_specific_table_BUDNI_HLG ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 null, +create_time timestamp DEFAULT current_timestamp +); + + diff --git a/MMT_SQL/onetime/create_tables_BUDNI_LCG.txt b/MMT_SQL/onetime/create_tables_BUDNI_LCG.txt new file mode 100644 index 0000000..99e3954 --- /dev/null +++ b/MMT_SQL/onetime/create_tables_BUDNI_LCG.txt @@ -0,0 +1,201 @@ +drop table if exists mmt_staging2.BUDNI_LCG_Spec_H1_Block; + +drop table if exists mmt_staging2.BUDNI_LCG_Gravity_Test_Block; + + + +create table mmt_staging2.BUDNI_LCG_Spec_H1_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +Tractor_HP text, +Rated_RPM text, +configuration text, +Transmission_type text, +Wheel_Drive_type text, +Wheel_Base text, +Wheel_track text, +Overall_height text, +Ballast_Condition text, +Tractor_Weight_reactions_Front text, +Tractor_Weight_reactions_Rear text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.BUDNI_LCG_Gravity_Test_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column2 text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + + +create TABLE mmt_staging2.stg_process_table_BUDNI_LCG ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 NULL, +create_time timestamp DEFAULT current_timestamp, +rank int4 NULL, +rank_tag text null +); + + +CREATE TABLE mmt_staging2.stg_specific_table_BUDNI_LCG ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 null, +create_time timestamp DEFAULT current_timestamp +); + + + + diff --git a/MMT_SQL/onetime/create_tables_BUDNI_NMT.txt b/MMT_SQL/onetime/create_tables_BUDNI_NMT.txt new file mode 100644 index 0000000..37ee828 --- /dev/null +++ b/MMT_SQL/onetime/create_tables_BUDNI_NMT.txt @@ -0,0 +1,348 @@ +drop table if exists mmt_staging2.BUDNI_NMT_Spec_H1_Block; +drop table if exists mmt_staging2.budni_nmt_noise_at_bystander_position_block; +drop table if exists mmt_staging2.BUDNI_NMT_Atmos_Cond_1_Block; +drop table if exists mmt_staging2.BUDNI_NMT_Meas_Results_1_Block; +drop table if exists mmt_staging2.budni_nmt_noise_at_operator_ear_level_block; +drop table if exists mmt_staging2.BUDNI_NMT_Atmos_Cond_2_Block; +drop table if exists mmt_staging2.BUDNI_NMT_Meas_Results_2_Block; +drop table if exists mmt_staging2.BUDNI_NMT_Test_Obs_Summary_Block; +drop table if exists mmt_staging2.stg_process_table_budni_nmt; +drop table if exists mmt_staging2.stg_specific_table_budni_nmt; + + +create table mmt_staging2.BUDNI_NMT_Spec_H1_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +tractor_HP text, +rated_rpm text, +configuration text, +transmission_type text, +wheel_drive_type text, +FIP_type text, +steering_type text, +Engine_to_PTO_ratio text, +Ballast_Condition text, +Test_Engine_Set_RPM text, +Type_of_track text , +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.BUDNI_NMT_Atmos_Cond_1_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column2 text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +ods_record int default 1, +rank int +); + +create table mmt_staging2.BUDNI_NMT_Noise_at_bystander_position_block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column2 text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.BUDNI_NMT_Meas_Results_1_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column2 text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.BUDNI_NMT_Noise_at_operator_ear_level_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column2 text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.BUDNI_NMT_Atmos_Cond_2_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column2 text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.BUDNI_NMT_Meas_Results_2_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column2 text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.BUDNI_NMT_Test_Obs_Summary_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column2 text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create TABLE mmt_staging2.stg_process_table_BUDNI_NMT ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 NULL, +create_time timestamp DEFAULT current_timestamp, +rank int4 NULL, +rank_tag text null +); + + +CREATE TABLE mmt_staging2.stg_specific_table_BUDNI_NMT ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 null, +create_time timestamp DEFAULT current_timestamp +); + + diff --git a/MMT_SQL/onetime/create_tables_budni_pto.sql b/MMT_SQL/onetime/create_tables_BUDNI_PTO.txt similarity index 95% rename from MMT_SQL/onetime/create_tables_budni_pto.sql rename to MMT_SQL/onetime/create_tables_BUDNI_PTO.txt index 5a54ff5..f0ce3ec 100644 --- a/MMT_SQL/onetime/create_tables_budni_pto.sql +++ b/MMT_SQL/onetime/create_tables_BUDNI_PTO.txt @@ -28,7 +28,8 @@ steering_type text, Engine_to_PTO_ratio text, date date, ods_record int default 1, -rank int +rank int, +create_time timestamp DEFAULT current_timestamp ); create table mmt_staging2.BUDNI_PTO_Perf_Report_Block @@ -52,7 +53,8 @@ column8 text, column9 text, column10 text, ods_record int default 1, -rank int +rank int, +create_time timestamp DEFAULT current_timestamp ); create table mmt_staging2.BUDNI_PTO_MMTKeyword1_Block @@ -78,7 +80,8 @@ column10 text, column11 text, column12 text, ods_record int default 1, -rank int +rank int, +create_time timestamp DEFAULT current_timestamp ); create table mmt_staging2.BUDNI_PTO_MMTKeyword2_Block @@ -104,7 +107,8 @@ column10 text, column11 text, column12 text, ods_record int default 1, -rank int +rank in, +create_time timestamp DEFAULT current_timestamp ); create table mmt_staging2.BUDNI_PTO_Summary_Block @@ -130,7 +134,8 @@ column10 text, column11 text, column12 text, ods_record int default 1, -rank int +rank int, +create_time timestamp DEFAULT current_timestamp ); create TABLE mmt_staging2.stg_process_table_BUDNI_PTO ( diff --git a/MMT_SQL/onetime/create_tables_BUDNI_VMT.txt b/MMT_SQL/onetime/create_tables_BUDNI_VMT.txt new file mode 100644 index 0000000..322678e --- /dev/null +++ b/MMT_SQL/onetime/create_tables_BUDNI_VMT.txt @@ -0,0 +1,224 @@ +drop table if exists mmt_staging2.BUDNI_VMT_Spec_H1_Block; +drop table if exists mmt_staging2.BUDNI_VMT_Meas_Test_Block; +drop table if exists mmt_staging2.BUDNI_VMT_Test_Obs_Summary_Block; +drop table if exists mmt_staging2.stg_process_table_BUDNI_VMT; +drop table if exists mmt_staging2.stg_specific_table_BUDNI_VMT; + + +create table mmt_staging2.BUDNI_VMT_Spec_H1_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +tractor_HP text, +rated_rpm text, +configuration text, +transmission_type text, +wheel_drive_type text, +FIP_type text, +steering_type text, +Engine_to_PTO_ratio text, +Ballast_Condition text, +Test_Engine_Set_RPM text, +Type_of_track text , +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.BUDNI_VMT_Perf_Meas_Test_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.BUDNI_VMT_Test_Obs_Summary_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +make text, +model text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +column8 text, +column9 text, +ods_record int default 1, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create TABLE mmt_staging2.stg_process_table_BUDNI_VMT ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 NULL, +create_time timestamp DEFAULT current_timestamp, +rank int4 NULL, +rank_tag text null +); + + +CREATE TABLE mmt_staging2.stg_specific_table_BUDNI_VMT ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 null, +create_time timestamp DEFAULT current_timestamp +); + + diff --git a/MMT_SQL/onetime/create_tables_FTDRY_SUM.txt b/MMT_SQL/onetime/create_tables_FTDRY_SUM.txt new file mode 100644 index 0000000..9a5ee6b --- /dev/null +++ b/MMT_SQL/onetime/create_tables_FTDRY_SUM.txt @@ -0,0 +1,335 @@ +SET search_path TO mmt_staging2; + + +drop table if exists mmt_staging2.FTDRY_SUM_Trac_H1_Block; + +drop table if exists mmt_staging2.FTDRY_SUM_Implement_Block; + +drop table if exists mmt_staging2.FTDRY_SUM_Test_Condition_1_Block; + +drop table if exists mmt_staging2.FTDRY_SUM_Test_Condition_2_Block; + +drop table if exists mmt_staging2.FTDRY_SUM_Comments_By_Block; + +drop table if exists mmt_staging2.stg_process_table_ftdry_sum; + +drop table if exists mmt_staging2.stg_specific_table_ftdry_sum; + +create table mmt_staging2.FTDRY_SUM_Trac_H1_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Tractor_Model text, +Tractor_Make text, +Tractor_Engine_HP text, +Rated_RPM text, +Transmission_Type text, +Wheel_Drive_Type text, +FIP_Type text, +Steering_Type text, +Tractor_Weight_kg_Front text, +Tractor_Weight_kg_Rear text, +Tractor_Weight_kg_Total text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + + +create table mmt_staging2.FTDRY_SUM_Implement_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Make_of_Implement text, +Implement_Type text, +Implement_Size text, +Hitch_Category text, +Implement_Weight text, +Soil_Type text, +Moisture_Content text, +Bulk_Density_g_cc text, +Soil_Cone_index text, +Field_Condition text, +Season text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.FTDRY_SUM_Test_Condition_1_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Test_Condition text, +Test_Date text, +Tractor_Model text, +Engine_RPM_set text, +PTO_RPM_set text, +Gear_Used text, +Nominal_Speed_KMPH text, +Engine_RPM_Drop_on_straight text, +Engine_RPM_Drop_on_turn text, +Depth_of_cut_cm text, +No_load_speed_kmph text, +On_load_speed_kmph text, +wheel_slippage_ text, +Fuel_consumption_lit_hr text, +Area_covered_acr_hr text, +Fuel_consumption_lit_Acr text, +M_M_Performance_in_compared_to_respective_competitor_tractors text, +Fuel_consumption_lit_hr_2 text, +Area_covered_acr_hr_2 text, +Fuel_consumption_lit_Acr_2 text, +Trail_Observations text, +Engine_Smoke_on_Load text, +Engine_acceleration_smoke text, +Draft_Response text, +Tractor_Steer_ability text, +Tractor_braking_performance text, +Front_Visibility text, +Implement_Accessibility text, +Front_Wheel_dragging_at_turning text, +Front_end_lifting_during_operation text, +RPM_Recovery_Time text, +Engine_Vibration text, +Engine_Sound text, +Implement_Lifting_Lowering_response text, +Pulverization_Quality text, +Pulverization_Index text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.FTDRY_SUM_Test_Condition_2_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Test_Condition text, +Test_Date text, +Tractor_Model text, +Engine_RPM_set text, +PTO_RPM_set text, +Gear_Used text, +Nominal_Speed_KMPH text, +Engine_RPM_Drop_on_straight text, +Engine_RPM_Drop_on_turn text, +Depth_of_cut_cm text, +No_load_speed_kmph text, +On_load_speed_kmph text, +wheel_slippage_ text, +Fuel_consumption_lit_hr text, +Area_covered_acr_hr text, +Fuel_consumption_lit_Acr text, +M_M_Performance_in_compared_to_respective_competitor_tractors text, +Fuel_consumption_lit_hr_2 text, +Area_covered_acr_hr_2 text, +Fuel_consumption_lit_Acr_2 text, +Trail_Observations text, +Engine_Smoke_on_Load text, +Engine_acceleration_smoke text, +Draft_Response text, +Tractor_Steer_ability text, +Tractor_braking_performance text, +Front_Visibility text, +Implement_Accessibility text, +Front_Wheel_dragging_at_turning text, +Front_end_lifting_during_operation text, +RPM_Recovery_Time text, +Engine_Vibration text, +Engine_Sound text, +Implement_Lifting_Lowering_response text, +Pulverization_Quality text, +Pulverization_Index text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.FTDRY_SUM_Comments_By_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Tractor_model text, +Test_Engineer_Comments_1 text, +Test_Manager_Comments_1 text, +Test_Engineer_Comments_2 text, +Test_Manager_Comments_2 text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + + + +create TABLE mmt_staging2.stg_process_table_ftdry_sum ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 NULL, +create_time timestamp DEFAULT current_timestamp, +rank int4 NULL, +rank_tag text null +); + + +CREATE TABLE mmt_staging2.stg_specific_table_ftdry_sum ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 null, +create_time timestamp DEFAULT current_timestamp +); + + diff --git a/MMT_SQL/onetime/create_tables_FTDRY_TRS.txt b/MMT_SQL/onetime/create_tables_FTDRY_TRS.txt new file mode 100644 index 0000000..2e6e7f8 --- /dev/null +++ b/MMT_SQL/onetime/create_tables_FTDRY_TRS.txt @@ -0,0 +1,303 @@ +SET search_path TO mmt_staging2; + +drop table if exists mmt_staging2.FTDRY_TRS_H1_INT; + +drop table if exists mmt_staging2.ftdry_trs_h1_block ; + +drop table if exists mmt_staging2.ftdry_trs_implement_block ; + +drop table if exists mmt_staging2.ftdry_trs_spec_block; + +drop table if exists mmt_staging2.ftdry_trs_engine_rpm_block; + +drop table if exists mmt_staging2.stg_process_table_ftdry_trs; + +drop table if exists mmt_staging2.stg_specific_table_ftdry_trs; + +/* FTDRY_TRS starts */ + +create table mmt_staging2.FTDRY_TRS_H1_INT +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +column2 text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.FTDRY_TRS_H1_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Report_Reference_No text, +Objective_Of_Test text, +Background_of_Test text, +Job_Order_No text, +Test_Location text, +Soil_Moisture_Content_ text, +Soil_Bulk_Density_g_cc text, +Test_Engineer text, +Test_Operator text, +Date_of_Test text, +Report_Date text, +Season text, +Type_of_Soil text, +Soil_Cone_Index_kPa text, +Field_Condition text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + + +create table mmt_staging2.FTDRY_TRS_SPEC_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Tractor_Model text, +Tractor_Make text, +Tractor_Sr_No text, +Tractor_Engine_HP text, +FIP_Type text, +hour_Meter_Reading text, +Steering_Type text, +Transmission_Type text, +Wheel_Drive_Type_WD text, +EGR_Yes_No text, +Brake_Type text, +PTO_Type text, +Standard_PTO_Speed_RPM text, +EPTO_Speed_RPM text, +Front_Tyre_Make text, +Front_Tyre_Size text, +Front_Tyre_Pressure_psi text, +Rear_Tyre_Make text, +Rear_Tyre_Size text, +Rear_Tyre_Pressure_psi text, +Tractor_Weight_kg_Front text, +Tractor_Weight_kg_Rear text, +Tractor_Weight_kg_Total text, +Ballasted_Tractor_Accessories text, +Mechanical_Ballast_Rear text, +Mechanical_Ballast_Rear_in_KG text, +Water_Ballast_Rear text, +Mechanical_Ballast_Front text, +Mechanical_Ballast_Front_in_Kg text, +Total_Ballast_Weight text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.FTDRY_TRS_Engine_RPM_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Tractor_model text, +Tractor_make text, +Low_Idle text, +High_Idle text, +Rated_RPM text, +Engine_to_PTO_Ratio_540_PTO text, +Engine_to_PTO_Ratio_540E_PTO text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.FTDRY_TRS_Implement_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Name_of_Implement text, +Type_of_Implement text, +Make_of_Implement text, +No_of_bottoms_Tyne_Disc_Blade text, +Cutting_Width_m text, +Implement_Weight_Kg text, +Hitch_Category text, +Span_cm_For_Mounted_Implement text, +Mast_Height_cm_For_Mounted_Implement text, +FDPD_TDC_Mar15_008 text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create TABLE mmt_staging2.stg_process_table_ftdry_trs ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 NULL, +create_time timestamp DEFAULT current_timestamp, +rank int4 NULL, +rank_tag text null +); + + +CREATE TABLE mmt_staging2.stg_specific_table_ftdry_trs ( +generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 null, +create_time timestamp DEFAULT current_timestamp +); + +/* FTDRY_TRS ends */ diff --git a/MMT_SQL/onetime/create_tables_FTHLG_SUM.txt b/MMT_SQL/onetime/create_tables_FTHLG_SUM.txt new file mode 100644 index 0000000..81efbe1 --- /dev/null +++ b/MMT_SQL/onetime/create_tables_FTHLG_SUM.txt @@ -0,0 +1,322 @@ +SET search_path TO mmt_staging2; + +drop table if exists mmt_staging2.FTHLG_SUM_Trac_H1_Block; + +drop table if exists mmt_staging2.FTHLG_SUM_Trail_Type_Block; + +drop table if exists mmt_staging2.FTHLG_SUM_Test_Condition_1_Block; + +drop table if exists mmt_staging2.FTHLG_SUM_Test_Condition_2_Block; + +drop table if exists mmt_staging2.FTHLG_SUM_Comments_By_Block; + + +drop table if exists mmt_staging2.stg_process_table_fthlg_sum; + + +drop table if exists mmt_staging2.stg_specific_table_fthlg_sum; + + +create table mmt_staging2.FTHLG_SUM_Trac_H1_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +tractor_model text, +tractor_make text, +tractor_engine_hp text, +rated_rpm text, +transmission_type text, +wheel_drive_type text, +fip_type text, +steering_type text, +tractor_weight_kg_front text, +tractor_weight_kg_rear text, +tractor_weight_kg_total text, +create_time timestamp DEFAULT current_timestamp +); + + + +create table mmt_staging2.FTHLG_SUM_Trail_Type_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Trailer_Type text, +Tire_size_and_inflation_pressure_psi text, +No_Of_Axle text, +No_Of_Wheels text, +Trailer_Gross_Weight_Kg text, +Tractor_Rear_Wheel_Center_to_Hitch_Point_Center_Distance_mm text, +Tractor_Hitch_Height_from_Ground_mm text, +Trailer_hitch_Height_above_ground_level_mm text, +Gradient_Slope_1_Degree text, +Gradient_Slope_2_degree text, +Tractor_Hitch_Type text +); + +create table mmt_staging2.FTHLG_SUM_Test_Condition_1_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Test_Condition text, +Test_Date text, +Tractor_Model text, +Fuel_consumption_Ltr_hr text, +Mileage_Km_Ltr text, +Average_speed_of_travel_kmph text, +Total_distance_travelled_km text, +Gear_used_on_Straight_Road text, +Straight_road_RPM_Drop text, +Gear_used_on_Up_Slope_1 text, +Up_Slope_RPM_Drop_1 text, +Gear_used_on_Up_Slope_2 text, +Up_Slope_RPM_Drop_2 text, +Gear_used_on_Down_Slope text, +Down_Slope_RPM_Shoot_up text, +M_M_Performance_compared_to_respective_competitor_tractors_is_better_and_is_poor_than_competitor text, +Fuel_consumption_lit_hr_2 text, +Mileage_Km_Ltr_2 text, +M_M_Performance_in_compared_to_respective_competitor_tractors text, +Fuel_consumption_lit_hr_3 text, +Mileage_Km_Ltr_3 text, +Engine_Smoke_on_Load text, +Engine_acceleration_smoke text, +Range_Gear_Shifting text, +Speed_Gear_Shifting text, +Tractor_Steer_ability text, +Tractor_braking_performance text, +Front_Visibility text, +Implement_Accessibility text, +Front_end_lifting_during_operation text, +RPM_Recovery_Time text, +Engine_Vibration text, +Engine_Sound text, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.FTHLG_SUM_Test_Condition_2_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Test_Condition text, +Test_Date text, +Tractor_Model text, +Fuel_consumption_Ltr_hr text, +Mileage_Km_Ltr text, +Average_speed_of_travel_kmph text, +Total_distance_travelled_km text, +Gear_used_on_Straight_Road text, +Straight_road_RPM_Drop text, +Gear_used_on_Up_Slope_1 text, +Up_Slope_RPM_Drop_1 text, +Gear_used_on_Up_Slope_2 text, +Up_Slope_RPM_Drop_2 text, +Gear_used_on_Down_Slope text, +Down_Slope_RPM_Shoot_up text, +M_M_Performance_compared_to_respective_competitor_tractors_is_better_and_is_poor_than_competitor text, +Fuel_consumption_lit_hr_2 text, +Mileage_Km_Ltr_2 text, +M_M_Performance_in_compared_to_respective_competitor_tractors text, +Fuel_consumption_lit_hr_3 text, +Mileage_Km_Ltr_3 text, +Engine_Smoke_on_Load text, +Engine_acceleration_smoke text, +Range_Gear_Shifting text, +Speed_Gear_Shifting text, +Tractor_Steer_ability text, +Tractor_braking_performance text, +Front_Visibility text, +Implement_Accessibility text, +Front_end_lifting_during_operation text, +RPM_Recovery_Time text, +Engine_Vibration text, +Engine_Sound text, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.FTHLG_SUM_Comments_By_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Tractor_Model text, +Test_Engineer_Comments_1 text, +Test_Manager_Comments_1 text, +Test_Engineer_Comments_2 text, +Test_Manager_Comments_2 text, +create_time timestamp DEFAULT current_timestamp +); + + + + +create TABLE mmt_staging2.stg_process_table_fthlg_sum ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 NULL, +create_time timestamp DEFAULT current_timestamp, +rank int4 NULL, +rank_tag text null +); + + +CREATE TABLE mmt_staging2.stg_specific_table_fthlg_sum ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 null, +create_time timestamp DEFAULT current_timestamp +); + + + + diff --git a/MMT_SQL/onetime/create_tables_FTHLG_TRS.txt b/MMT_SQL/onetime/create_tables_FTHLG_TRS.txt new file mode 100644 index 0000000..6fb040f --- /dev/null +++ b/MMT_SQL/onetime/create_tables_FTHLG_TRS.txt @@ -0,0 +1,312 @@ + +SET search_path TO mmt_staging2; + +drop table if exists mmt_staging2.FTHLG_TRS_H1_INT; + +drop table if exists mmt_staging2.FTHLG_TRS_H1_Block; + +drop table if exists mmt_staging2.FTHLG_TRS_SPEC_Block; + +drop table if exists mmt_staging2.FTHLG_TRS_Engine_RPM_Block; + +drop table if exists mmt_staging2.FTHLG_TRS_Trailer_Block; + +drop table if exists mmt_staging2.stg_specific_table_fthlg_trs; + +drop table if exists mmt_staging2.stg_process_table_fthlg_trs; + + +create table mmt_staging2.FTHLG_TRS_H1_INT +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +column2 text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.FTHLG_TRS_H1_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Report_Reference_No text, +Objective_Of_Test text, +Background_of_Test text, +Job_Order_No text, +Test_Location text, +Gradient_Slope_1_Degree text, +Gradient_Slope_2_Degree text, +Tractor_Hitch_Type text, +Test_Engineer text, +Test_Operator text, +Date_of_Test text, +Report_Date text, +Type_of_Road text, +Tractor_Hitch_Height_from_Ground_mm text, +Tractor_Rear_Wheel_Center_to_Hitch_Point_Center_Distance_mm text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + + +create table mmt_staging2.FTHLG_TRS_SPEC_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Tractor_Model text, +Tractor_Make text, +Tractor_Sr_No text, +Tractor_Engine_HP text, +FIP_Type text, +Hour_Meter_Reading text, +Steering_Type text, +Transmission_Type text, +Wheel_Drive_Type_WD text, +EGR_Yes_No text, +Brake_Type text, +PTO_Type text, +Standard_PTO_Speed_RPM text, +EPTO_Speed_RPM text, +Front_Tyre_Make text, +Front_Tyre_Size text, +Front_Tyre_Pressure_psi text, +Rear_Tyre_Make text, +Rear_Tyre_Size text, +Rear_Tyre_Pressure_psi text, +Tractor_Weight_kg_Front text, +Tractor_Weight_kg_Rear text, +Tractor_Weight_kg_Total text, +Ballasted_Tractor_Accessories text, +Mechanical_Ballast_Rear text, +Mechanical_Ballast_Rear_in_kg text, +Water_Ballast_Rear_75 text, +Mechanical_Ballast_Front_in_kg text, +Mechanical_Ballast_Front text, +Total_Ballast_Weight text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.FTHLG_TRS_Engine_RPM_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Tractor_model text, +Tractor_make text, +Low_Idle text, +High_Idle text, +Rated_RPM text, +Engine_to_PTO_Ratio_540_PTO text, +Engine_to_PTO_Ratio_540E_PTO text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.FTHLG_TRS_Trailer_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Type_Of_Trailer text, +No_Of_Axle text, +No_Of_Wheels text, +Trailer_hitch_Height_above_ground_level_mm text, +Make_model_of_trailer text, +Trailer_platform_length_mm text, +Trailer_platform_Width_mm text, +Trailer_platform_Height_mm text, +Tire_size text, +Inflation_pressure_psi text, +Track_width_of_trailer_mm text, +Horizontal_distance_of_hitch_point_from_trailer_front_face_mm text, +Tractor_Rear_Wheel_Center_to_Hitch_Point_Center_Distance_mm text, +Distance_from_Trailerfront_axle_distance_from_hitch_point_mm text, +Distance_from_tractor_rear_wheel_center_to_tractor_rear_wheel_center_mm text, +Trailer_empty_weight_Kg text, +Trailer_Gross_Weight_Kg text, +FDPD_TDC_Mar15_009 text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + + + +create TABLE mmt_staging2.stg_process_table_fthlg_trs ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 NULL, +create_time timestamp DEFAULT current_timestamp, +rank int4 NULL, +rank_tag text null +); + + +CREATE TABLE mmt_staging2.stg_specific_table_fthlg_trs ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 null, +create_time timestamp DEFAULT current_timestamp +); diff --git a/MMT_SQL/onetime/create_tables_FTWET_SUM.txt b/MMT_SQL/onetime/create_tables_FTWET_SUM.txt new file mode 100644 index 0000000..e2c4a9c --- /dev/null +++ b/MMT_SQL/onetime/create_tables_FTWET_SUM.txt @@ -0,0 +1,302 @@ +SET search_path TO mmt_staging2; + + +drop table if exists mmt_staging2.FTWET_SUM_Trac_H1_Block; + +drop table if exists mmt_staging2.FTWET_SUM_Implement_Block; + +drop table if exists mmt_staging2.FTWET_SUM_Cage_Wheel_Block; +; +drop table if exists mmt_staging2.FTWET_SUM_Test_Condition_Block; + +drop table if exists mmt_staging2.FTWET_SUM_Comments_By_Block; + +drop table if exists mmt_staging2.stg_process_table_ftwet_sum; + +drop table if exists mmt_staging2.stg_specific_table_ftwet_sum; + + +create table mmt_staging2.FTWET_SUM_Trac_H1_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Tractor_Model text, +Tractor_Make text, +Tractor_Engine_HP text, +Rated_RPM text, +Transmission_Type text, +Wheel_Drive_Type text, +FIP_Type text, +Steering_Type text, +Tractor_Weight_kg_Front text, +Tractor_Weight_kg_Rear text, +Tractor_Weight_kg_Total text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.FTWET_SUM_Implement_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Make_of_Implement text, +Implement_Type text, +Implement_Size text, +Hitch_Category text, +Implement_Weight text, +Soil_Type text, +Moisture_Content text, +Bulk_Density_g_cc text, +Soil_Cone_index text, +Field_Condition text, +Season text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.FTWET_SUM_Cage_Wheel_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Type_of_Cage_Wheel text, +Cage_Wheel_Width_mm text, +Cage_wheel_Weight text, +Cage_Wheel_inner_Outer_Ring_Dia_mm text, +Cage_Wheel_Center_Ring_Dia_mm text, +Distance_between_RHS_LHS_cage_wheel_Inner_Ring_mm text, +No_of_angles_on_cage_wheel text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.FTWET_SUM_Test_Condition_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Test_Condition text, +Test_Date text, +Tractor_Model text, +Engine_RPM_set text, +PTO_RPM_set text, +Gear_Used text, +Nominal_Speed_KMPH text, +Engine_RPM_Drop_on_straight_1st_Pass text, +Engine_RPM_Drop_on_straight_2nd_Pass text, +Engine_RPM_Drop_on_straight_3rd_Pass text, +Engine_RPM_Drop_on_turn_1st_Pass text, +Engine_RPM_Drop_on_turn_2nd_Pass text, +Engine_RPM_Drop_on_turn_3rd_Pass text, +No_of_passes text, +Avg_Depth_of_cut_cm text, +Fuel_consumption_lit_hr text, +Area_covered_acr_hr text, +Fuel_consumption_lit_Acr text, +M_M_Performance_in_compared_to_respective_competitor_tractors text, +Fuel_consumption_lit_hr_2 text, +Area_covered_acr_hr_2 text, +Fuel_consumption_lit_Acr_2 text, +Trail_Observations text, +Engine_Smoke_on_Load text, +Engine_acceleration_smoke text, +Draft_Response text, +Tractor_Steer_ability text, +Tractor_braking_performance text, +Front_Visibility text, +Implement_Accessibility text, +Front_Wheel_dragging_at_turning text, +Front_end_lifting_during_operation text, +RPM_Recovery_Time text, +Engine_Vibration text, +Engine_Sound text, +Implement_Lifting_Lowering_response text, +Pulverization_Quality text, +Pulverization_Index text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.FTWET_SUM_Comments_By_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Tractor_Model text, +Test_Manager_Comments text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create TABLE mmt_staging2.stg_process_table_ftwet_sum ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 NULL, +create_time timestamp DEFAULT current_timestamp, +rank int4 NULL, +rank_tag text null +); + + +CREATE TABLE mmt_staging2.stg_specific_table_ftwet_sum ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 null, +create_time timestamp DEFAULT current_timestamp +); + diff --git a/MMT_SQL/onetime/create_tables_FTWET_TRS.txt b/MMT_SQL/onetime/create_tables_FTWET_TRS.txt new file mode 100644 index 0000000..f014089 --- /dev/null +++ b/MMT_SQL/onetime/create_tables_FTWET_TRS.txt @@ -0,0 +1,313 @@ + +SET search_path TO mmt_staging2; + + +drop table if exists mmt_staging2.FTWET_TRS_H1_INT; + +drop table if exists mmt_staging2.FTWET_TRS_H1_Block; + +drop table if exists mmt_staging2.FTWET_TRS_SPEC_Block; + +drop table if exists mmt_staging2.FTWET_TRS_Engine_RPM_Block; + +drop table if exists mmt_staging2.FTWET_TRS_Implement_Block; + +drop table if exists mmt_staging2.stg_process_table_ftwet_trs; + +drop table if exists mmt_staging2.stg_specific_table_ftwet_trs; + + +/* FTWET_TRS starts */ +create table mmt_staging2.FTWET_TRS_H1_INT +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +column2 text, +column3 text, +column4 text, +column5 text, +column6 text, +column7 text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.FTWET_TRS_H1_Block +( +syspk serial, +file_syspk int, +client_id int, +function_id int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Report_Reference_No text, +Objective_Of_Test text, +Background_of_Test text, +Job_Order_No text, +Test_Location text, +Soil_Moisture_Content_ text, +Soil_Bulk_Density_g_cc text, +Test_Engineer text, +Test_Operator text, +Date_of_Test text, +Report_Date text, +Season text, +Type_of_Soil text, +Soil_Cone_Index_kPa text, +Field_Condition text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.FTWET_TRS_SPEC_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Tractor_Model text, +Tractor_Make text, +Tractor_Sr_No text, +Tractor_Engine_HP text, +FIP_Type text, +hour_Meter_Reading text, +Steering_Type text, +Transmission_Type text, +Wheel_Drive_Type_WD text, +EGR_Yes_No text, +Brake_Type text, +PTO_Type text, +Standard_PTO_Speed_RPM text, +EPTO_Speed_RPM text, +Front_Tyre_Make text, +Front_Tyre_Size text, +Front_Tyre_Pressure_psi text, +Rear_Tyre_Make text, +Rear_Tyre_Size text, +Rear_Tyre_Pressure_psi text, +Tractor_Weight_kg_Front text, +Tractor_Weight_kg_Rear text, +Tractor_Weight_kg_Total text, +Ballasted_Tractor_Accessories text, +Mechanical_Ballast_Rear_in_KG text, +Water_Ballast_Rear text, +Mechanical_Ballast_Front text, +Mechanical_Ballast_Front_in_Kg text, +Total_Ballast_Weight text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.FTWET_TRS_Engine_RPM_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Tractor_model text, +Tractor_make text, +Low_Idle text, +High_Idle text, +Rated_RPM text, +Engine_to_PTO_Ratio_540_PTO text, +Engine_to_PTO_Ratio_540E_PTO text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.FTWET_TRS_Implement_Block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +file_format text, +sheet_mnemonic text, +dummy_f text, +Name_of_Implement text, +Type_of_Implement text, +Make_of_Implement text, +No_of_bottoms_Tyne_Disc_Blade text, +Cutting_Width_m text, +Implement_Weight_Kg text, +Hitch_Category text, +Span_cm_For_Mounted_Implement text, +Mast_Height_cm_For_Mounted_Implement text, +Type_of_Cage_Wheel_Half_Cage_wheel_Full_Cage_Wheel text, +Cage_Wheel_Width_mm text, +Cage_wheel_Weight text, +Cage_Wheel_inner_Outer_Ring_Dia_mm text, +Cage_Wheel_Center_Ring_Dia_mm text, +Distance_between_RHS_LHS_cage_wheel_Inner_Ring_mm_For_Full_Cage_wheel text, +No_of_angles_on_cage_wheel text, +No_of_days_of_water_logging text, +Depth_of_water_mm text, +FDPD_TDC_Mar15_008 text, +rank, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + + + +create TABLE mmt_staging2.stg_process_table_ftwet_trs ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 NULL, +create_time timestamp DEFAULT current_timestamp, +rank int4 NULL, +rank_tag text null +); + + +CREATE TABLE mmt_staging2.stg_specific_table_ftwet_trs ( + generic_syspk int, +file_syspk bigint, +file_name varchar(1024) NULL, +file_date date NULL, +file_format varchar(1024) NULL, +sheet_number int4 NULL, +sheet_name varchar(1024) NULL, +sheet_format text, +sheet_mnemonic varchar(1024) NULL, +row_number int4 NULL, +file_creation_date timestamp NULL, +column1 varchar(1024) NULL, +column2 varchar(1024) NULL, +column3 varchar(1024) NULL, +column4 varchar(1024) NULL, +column5 varchar(1024) NULL, +column6 varchar(1024) NULL, +column7 varchar(1024) NULL, +column8 varchar(1024) NULL, +column9 varchar(1024) NULL, +column10 varchar(1024) NULL, +column11 varchar(1024) NULL, +column12 varchar(1024) NULL, +column13 varchar(1024) NULL, +column14 varchar(1024) NULL, +column15 varchar(1024) NULL, +column16 varchar(1024) NULL, +column17 varchar(1024) NULL, +column18 varchar(1024) NULL, +column19 varchar(1024) NULL, +column20 varchar(1024) NULL, +column21 varchar(1024) NULL, +column22 varchar(1024) NULL, +column23 varchar(1024) NULL, +column24 varchar(1024) NULL, +column25 varchar(1024) NULL, +column26 varchar(1024) NULL, +column27 varchar(1024) NULL, +column28 varchar(1024) NULL, +column29 varchar(1024) NULL, +column30 varchar(1024) NULL, +column31 varchar(1024) NULL, +column32 varchar(1024) NULL, +column33 varchar(1024) NULL, +column34 varchar(1024) NULL, +column35 varchar(1024) NULL, +column36 varchar(1024) NULL, +column37 varchar(1024) NULL, +column38 varchar(1024) NULL, +column39 varchar(1024) NULL, +column40 varchar(1024) NULL, +column41 varchar(1024) NULL, +column42 varchar(1024) NULL, +column43 varchar(1024) NULL, +column44 varchar(1024) NULL, +column45 varchar(1024) NULL, +column46 varchar(1024) NULL, +column47 varchar(1024) NULL, +column48 varchar(1024) NULL, +column49 varchar(1024) NULL, +column50 varchar(1024) NULL, +column51 varchar(1024) NULL, +column52 varchar(1024) NULL, +column53 varchar(1024) NULL, +is_rownumber_fetched int4 null, +create_time timestamp DEFAULT current_timestamp +); + diff --git a/MMT_SQL/onetime/create_tables_PTO.txt b/MMT_SQL/onetime/create_tables_PTO.txt new file mode 100644 index 0000000..f424c1e --- /dev/null +++ b/MMT_SQL/onetime/create_tables_PTO.txt @@ -0,0 +1,1402 @@ + +SET search_path TO mmt_staging2; + +drop table if exists mmt_staging2.stg_process_table_PTO_report; +drop table if exists mmt_staging2.stg_specific_table_PTO_report; +drop table if exists mmt_staging2.stg_specific_table_PTO_report; +drop table if exists mmt_staging2.stg_process_table_PTO_PNA; +drop table if exists mmt_staging2.stg_specific_table_PTO_PNA; +drop table if exists mmt_staging2.stg_process_table_PTO_PHA; +drop table if exists mmt_staging2.stg_specific_table_PTO_PHA; +drop table if exists mmt_staging2.stg_process_table_PTO_MPM; +drop table if exists mmt_staging2.stg_specific_table_PTO_MPM; +drop table if exists mmt_staging2.stg_process_table_PTO_GVG; +drop table if exists mmt_staging2.stg_specific_table_PTO_GVG; +drop table if exists mmt_staging2.PTOBST_RPT_tractor_specs_block; +drop table if exists mmt_staging2.PTOBST_RPT_PTO_performance_report_block; +drop table if exists mmt_staging2.PTOBST_RPT_MMTKeyword1_block; +drop table if exists mmt_staging2.PTOBST_RPT_MMTKeyword2_block; +drop table if exists mmt_staging2.PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block; +drop table if exists mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_int; +drop table if exists mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_block; +drop table if exists mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block; +drop table if exists mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block; +drop table if exists mmt_staging2.PTOBST_PNA_varying_speed_test_block; +drop table if exists mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block; +drop table if exists mmt_staging2.PTOBST_PNA_varying_load_block; +drop table if exists mmt_staging2.PTOBST_PNA_smoke_test_block; +drop table if exists mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_block; +drop table if exists mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block; +drop table if exists mmt_staging2.PTOBST_PHA_varying_speed_test_block; +drop table if exists mmt_staging2.PTOBST_PHA_Engine_oil_consumption_block; +drop table if exists mmt_staging2.ptobst_mpm_performance_boost_natuaral_block; +drop table if exists mmt_staging2.PTOBST_GVG_performance_governing_trails_block; + +create table mmt_staging2.PTOBST_RPT_tractor_specs_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make text, +model text, +tractor_HP text, +rated_rpm text, +configuration text, +transmission_type text, +wheel_drive_type text, +FIP_type text, +date text, +steering_type text, +Engine_to_PTO_ratio text, +rank int, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + + +create table mmt_staging2.PTOBST_RPT_PTO_performance_report_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make text, +model text, +c2 text, +c3 text, +c4 text, +c5 text, +c6 text, +c7 text, +c8 text, +c9 text, +c10 text, +rank int, +test_condition text, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.PTOBST_RPT_MMTKeyword1_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make text, +model text, +c2 text, +c3 text, +c4 text, +c5 text, +c6 text, +c7 text, +c8 text, +c9 text, +c10 text, +c11 text, +c12 text, +rank int, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.PTOBST_RPT_MMTKeyword2_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make text, +model text, +c2 text, +c3 text, +c4 text, +c5 text, +c6 text, +c7 text, +c8 text, +c9 text, +c10 text, +c11 text, +c12 text, +rank int, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make text, +model text, +c2 text, +c3 text, +c4 text, +c5 text, +c6 text, +c7 text, +c8 text, +c9 text, +c10 text, +c11 text, +c12 text, +rank int, +test_condition text, +ods_record int default 1, +create_time timestamp DEFAULT current_timestamp +); + +/*PNA*/ + +create table mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_int +( +file_syspk serial, +c1 text, +c2 text, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make text, +model text, +test_condition text, +PTO_SFC_gm_hp text, +PTO_power_hp text, +Test_engineer text, +Coolant_temp text, +Exhaust_temperature text, +Rated_engine_speed text, +Maximum_Equ_Crankshaft text, +Place text, +Relative_humidity text, +Test_bed text, +Total_run_hrs text, +Engine_low_idle_speed text, +Engine_high_Idle_speed text, +Ambient_pressure_mm_of_hg text, +Engine_oil_pressure_bar text, +Equ_crankshaft_torque_at_maximum_power text, +Specific_gravity_of_Fuel text, +Dyno_Constant text, +Backup_Torque text, +PTO_gear_ratio text, +Engine_oil_temp text, +Test_date text, +back_pressure text, +rank int, +ods_record int default 1 +); + +create table mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make text, +model text, +test_condition text, +c2 text, +c3 text, +c4 text, +c5 text, +c6 text, +c7 text, +c8 text, +c9 text, +c10 text, +c11 text, +c12 text, +c13 text, +c14 text, +c15 text, +c16 text, +c17 text, +c18 text, +c19 text, +c20 text, +c21 text, +c22 text, +c23 text, +c24 text, +c25 text, +rank int, +ods_record int default 1 +); + + + +create table mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make text, +model text, +test_condition text, +c2 text, +c3 text, +c4 text, +c5 text, +c6 text, +c7 text, +c8 text, +c9 text, +c10 text, +c11 text, +c12 text, +c13 text, +c14 text, +c15 text, +c16 text, +c17 text, +c18 text, +c19 text, +c20 text, +c21 text, +c22 text, +c23 text, +c24 text, +c25 text, +rank int, +ods_record int default 1 +); + + +create table mmt_staging2.PTOBST_PNA_varying_speed_test_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make text, +model text, +test_condition text, +c2 text, +c3 text, +c4 text, +c5 text, +c6 text, +c7 text, +c8 text, +c9 text, +c10 text, +c11 text, +c12 text, +c13 text, +c14 text, +c15 text, +c16 text, +c17 text, +c18 text, +c19 text, +c20 text, +c21 text, +c22 text, +c23 text, +c24 text, +c25 text, +rank int, +ods_record int default 1 +); + +create table mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make text, +model text, +test_condition text, +c1 text, +c2 text, +c3 text, +c4 text, +c5 text, +c6 text, +c7 text, +c8 text, +c9 text, +c10 text, +c11 text, +c12 text, +c13 text, +c14 text, +c15 text, +c16 text, +c17 text, +c18 text, +c19 text, +c20 text, +c21 text, +c22 text, +c23 text, +c24 text, +c25 text, +rank int, +ods_record int default 1 +); + + +create table mmt_staging2.PTOBST_PNA_varying_load_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make text, +model text, +test_condition text, +c1 text, +c2 text, +c3 text, +c4 text, +c5 text, +c6 text, +c7 text, +c8 text, +c9 text, +c10 text, +c11 text, +c12 text, +c13 text, +c14 text, +c15 text, +c16 text, +c17 text, +c18 text, +c19 text, +c20 text, +c21 text, +c22 text, +c23 text, +c24 text, +c25 text, +rank int, +ods_record int default 1 +); + + +create table mmt_staging2.PTOBST_PNA_smoke_test_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make text, +model text, +test_condition text, +c2 text, +c3 text, +c4 text, +c5 text, +c6 text, +c7 text, +rank int, +ods_record int default 1 +); + +/* PTA block */ + + +create table mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_int +( +file_syspk serial, +c1 text, +c2 text, +rank int, +create_time timestamp DEFAULT current_timestamp +); + +create table mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make text, +model text, +test_condition text, +PTO_SFC_gm_hp text, +PTO_power_hp text, +Test_engineer text, +Coolant_temp text, +Exhaust_temperature text, +Rated_engine_speed text, +Maximum_Equ_Crankshaft text, +Place text, +Relative_humidity text, +Test_bed text, +Total_run_hrs text, +Engine_low_idle_speed text, +Engine_high_Idle_speed text, +Ambient_pressure_mm_of_hg text, +Engine_oil_pressure_bar text, +Equ_crankshaft_torque_at_maximum_power text, +Specific_gravity_of_Fuel text, +Dyno_Constant text, +Backup_Torque text, +PTO_gear_ratio text, +Engine_oil_temp text, +Test_date text, +back_pressure text, +rank int, +ods_record int default 1 +); + + +create table mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make text, +model text, +test_condition text, +c2 text, +c3 text, +c4 text, +c5 text, +c6 text, +c7 text, +c8 text, +c9 text, +c10 text, +c11 text, +c12 text, +c13 text, +c14 text, +c15 text, +c16 text, +c17 text, +c18 text, +c19 text, +c20 text, +c21 text, +c22 text, +c23 text, +c24 text, +c25 text, +rank int, +ods_record int default 1 +); + + + +CREATE TABLE mmt_staging2.ptobst_pha_engine_oil_consumption_block ( + syspk serial NOT NULL, + client_id int4 NULL, + function_id int4 NULL, + file_syspk int4 NULL, + dummy_f text NULL, + file_format text NULL, + sheet_mnemonic text NULL, + make text NULL, + model text NULL, + test_condition text NULL, + c2 text NULL, + c3 text NULL, + c5 text NULL, + rank int NULL, + ods_record int4 NULL DEFAULT 1 +); + + +create table mmt_staging2.PTOBST_PHA_varying_speed_test_block +( +syspk serial, +client_id int, +function_id int, +file_syspk int, +dummy_f text, +file_format text, +sheet_mnemonic text, +make text, +model text, +test_condition text, +c2 text, +c3 text, +c4 text, +c5 text, +c6 text, +c7 text, +c8 text, +c9 text, +c10 text, +c11 text, +c12 text, +c13 text, +c14 text, +c15 text, +c16 text, +c17 text, +c18 text, +c19 text, +c20 text, +c21 text, +c22 text, +c23 text, +c24 text, +c25 text, +rank int, +ods_record int default 1 +); + + + +CREATE TABLE mmt_staging2.ptobst_mpm_performance_boost_natuaral_block ( + syspk serial NOT NULL, + client_id int4 NULL, + function_id int4 NULL, + file_syspk int4 NULL, + dummy_f text NULL, + file_format text NULL, + sheet_mnemonic text NULL, + make text NULL, + model text NULL, + test_condition text NULL, + c2 text NULL, + c3 text NULL, + c4 text NULL, + c5 text NULL, + rank int NULL, + ods_record int4 NULL DEFAULT 1, + create_time timestamp NULL DEFAULT CURRENT_TIMESTAMP +); + + +create TABLE mmt_staging2.PTOBST_GVG_performance_governing_trails_block ( +syspk serial NOT NULL, +client_id int4 NULL, +function_id int4 NULL, +file_syspk int4 NULL, +dummy_f text NULL, +file_format text NULL, +sheet_mnemonic text NULL, +make text NULL, +model text NULL, +test_condition text NULL, +c1 text null, +c2 text null, +c3 text null, +c4 text null, +c5 text null, +c6 text null, +c7_1 text null, +c7 text null, +c8 text null, +c9 text null, +c10 text null, +c11 text null, +c12_1 text null, +c12 text null, +c13 text null, +c14 text null, +c15 text null, +c16 text null, +c17_1 text null, +c17 text null, +c18 text null, +c19 text null, +c20 text null, +c21 text null, +c22_1 text null, +c22 text null, +c23 text null, +c24 text null, +c25 text null, +c26 text null, +c27 text null, +c27_1 text null, +c28 text null, +c29 text null, +c30 text null, +c31 text null, +c32_1 text null, +c32 text null, +c33 text null, +c34 text null, +c35 text null, +c36 text null, +rank int, +ods_record int4 NULL DEFAULT 1, +create_time timestamp NULL DEFAULT CURRENT_TIMESTAMP +); + + +/*sheet */ + +create TABLE mmt_staging2.stg_process_table_PTO_report ( + generic_syspk int, + file_syspk bigint, + file_name varchar(1024) NULL, + file_date date NULL, + file_format varchar(1024) NULL, + sheet_number int4 NULL, + sheet_name varchar(1024) NULL, + sheet_format text, + sheet_mnemonic varchar(1024) NULL, + row_number int4 NULL, + file_creation_date timestamp NULL, + column1 varchar(1024) NULL, + column2 varchar(1024) NULL, + column3 varchar(1024) NULL, + column4 varchar(1024) NULL, + column5 varchar(1024) NULL, + column6 varchar(1024) NULL, + column7 varchar(1024) NULL, + column8 varchar(1024) NULL, + column9 varchar(1024) NULL, + column10 varchar(1024) NULL, + column11 varchar(1024) NULL, + column12 varchar(1024) NULL, + column13 varchar(1024) NULL, + column14 varchar(1024) NULL, + column15 varchar(1024) NULL, + column16 varchar(1024) NULL, + column17 varchar(1024) NULL, + column18 varchar(1024) NULL, + column19 varchar(1024) NULL, + column20 varchar(1024) NULL, + column21 varchar(1024) NULL, + column22 varchar(1024) NULL, + column23 varchar(1024) NULL, + column24 varchar(1024) NULL, + column25 varchar(1024) NULL, + column26 varchar(1024) NULL, + column27 varchar(1024) NULL, + column28 varchar(1024) NULL, + column29 varchar(1024) NULL, + column30 varchar(1024) NULL, + column31 varchar(1024) NULL, + column32 varchar(1024) NULL, + column33 varchar(1024) NULL, + column34 varchar(1024) NULL, + column35 varchar(1024) NULL, + column36 varchar(1024) NULL, + column37 varchar(1024) NULL, + column38 varchar(1024) NULL, + column39 varchar(1024) NULL, + column40 varchar(1024) NULL, + column41 varchar(1024) NULL, + column42 varchar(1024) NULL, + column43 varchar(1024) NULL, + column44 varchar(1024) NULL, + column45 varchar(1024) NULL, + column46 varchar(1024) NULL, + column47 varchar(1024) NULL, + column48 varchar(1024) NULL, + column49 varchar(1024) NULL, + column50 varchar(1024) NULL, + column51 varchar(1024) NULL, + column52 varchar(1024) NULL, + column53 varchar(1024) NULL, + is_rownumber_fetched int4 NULL, + create_time timestamp DEFAULT current_timestamp, + rank int4 NULL, + rank_tag text null +); + + + +CREATE TABLE mmt_staging2.stg_specific_table_PTO_report ( + generic_syspk int, + file_syspk bigint, + file_name varchar(1024) NULL, + file_date date NULL, + file_format varchar(1024) NULL, + sheet_number int4 NULL, + sheet_name varchar(1024) NULL, + sheet_format text, + sheet_mnemonic varchar(1024) NULL, + row_number int4 NULL, + file_creation_date timestamp NULL, + column1 varchar(1024) NULL, + column2 varchar(1024) NULL, + column3 varchar(1024) NULL, + column4 varchar(1024) NULL, + column5 varchar(1024) NULL, + column6 varchar(1024) NULL, + column7 varchar(1024) NULL, + column8 varchar(1024) NULL, + column9 varchar(1024) NULL, + column10 varchar(1024) NULL, + column11 varchar(1024) NULL, + column12 varchar(1024) NULL, + column13 varchar(1024) NULL, + column14 varchar(1024) NULL, + column15 varchar(1024) NULL, + column16 varchar(1024) NULL, + column17 varchar(1024) NULL, + column18 varchar(1024) NULL, + column19 varchar(1024) NULL, + column20 varchar(1024) NULL, + column21 varchar(1024) NULL, + column22 varchar(1024) NULL, + column23 varchar(1024) NULL, + column24 varchar(1024) NULL, + column25 varchar(1024) NULL, + column26 varchar(1024) NULL, + column27 varchar(1024) NULL, + column28 varchar(1024) NULL, + column29 varchar(1024) NULL, + column30 varchar(1024) NULL, + column31 varchar(1024) NULL, + column32 varchar(1024) NULL, + column33 varchar(1024) NULL, + column34 varchar(1024) NULL, + column35 varchar(1024) NULL, + column36 varchar(1024) NULL, + column37 varchar(1024) NULL, + column38 varchar(1024) NULL, + column39 varchar(1024) NULL, + column40 varchar(1024) NULL, + column41 varchar(1024) NULL, + column42 varchar(1024) NULL, + column43 varchar(1024) NULL, + column44 varchar(1024) NULL, + column45 varchar(1024) NULL, + column46 varchar(1024) NULL, + column47 varchar(1024) NULL, + column48 varchar(1024) NULL, + column49 varchar(1024) NULL, + column50 varchar(1024) NULL, + column51 varchar(1024) NULL, + column52 varchar(1024) NULL, + column53 varchar(1024) NULL, + is_rownumber_fetched int4 null, + create_time timestamp DEFAULT current_timestamp +); + + + +create TABLE mmt_staging2.stg_process_table_PTO_PNA ( + generic_syspk int, + file_syspk bigint, + file_name varchar(1024) NULL, + file_date date NULL, + file_format varchar(1024) NULL, + sheet_number int4 NULL, + sheet_name varchar(1024) NULL, + sheet_format text, + sheet_mnemonic varchar(1024) NULL, + row_number int4 NULL, + file_creation_date timestamp NULL, + column1 varchar(1024) NULL, + column2 varchar(1024) NULL, + column3 varchar(1024) NULL, + column4 varchar(1024) NULL, + column5 varchar(1024) NULL, + column6 varchar(1024) NULL, + column7 varchar(1024) NULL, + column8 varchar(1024) NULL, + column9 varchar(1024) NULL, + column10 varchar(1024) NULL, + column11 varchar(1024) NULL, + column12 varchar(1024) NULL, + column13 varchar(1024) NULL, + column14 varchar(1024) NULL, + column15 varchar(1024) NULL, + column16 varchar(1024) NULL, + column17 varchar(1024) NULL, + column18 varchar(1024) NULL, + column19 varchar(1024) NULL, + column20 varchar(1024) NULL, + column21 varchar(1024) NULL, + column22 varchar(1024) NULL, + column23 varchar(1024) NULL, + column24 varchar(1024) NULL, + column25 varchar(1024) NULL, + column26 varchar(1024) NULL, + column27 varchar(1024) NULL, + column28 varchar(1024) NULL, + column29 varchar(1024) NULL, + column30 varchar(1024) NULL, + column31 varchar(1024) NULL, + column32 varchar(1024) NULL, + column33 varchar(1024) NULL, + column34 varchar(1024) NULL, + column35 varchar(1024) NULL, + column36 varchar(1024) NULL, + column37 varchar(1024) NULL, + column38 varchar(1024) NULL, + column39 varchar(1024) NULL, + column40 varchar(1024) NULL, + column41 varchar(1024) NULL, + column42 varchar(1024) NULL, + column43 varchar(1024) NULL, + column44 varchar(1024) NULL, + column45 varchar(1024) NULL, + column46 varchar(1024) NULL, + column47 varchar(1024) NULL, + column48 varchar(1024) NULL, + column49 varchar(1024) NULL, + column50 varchar(1024) NULL, + column51 varchar(1024) NULL, + column52 varchar(1024) NULL, + column53 varchar(1024) NULL, + is_rownumber_fetched int4 NULL, + create_time timestamp DEFAULT current_timestamp, + rank int4 NULL, + rank_tag text null +); + + + +CREATE TABLE mmt_staging2.stg_specific_table_PTO_PNA ( + generic_syspk int, + file_syspk bigint, + file_name varchar(1024) NULL, + file_date date NULL, + file_format varchar(1024) NULL, + sheet_number int4 NULL, + sheet_name varchar(1024) NULL, + sheet_format text, + sheet_mnemonic varchar(1024) NULL, + row_number int4 NULL, + file_creation_date timestamp NULL, + column1 varchar(1024) NULL, + column2 varchar(1024) NULL, + column3 varchar(1024) NULL, + column4 varchar(1024) NULL, + column5 varchar(1024) NULL, + column6 varchar(1024) NULL, + column7 varchar(1024) NULL, + column8 varchar(1024) NULL, + column9 varchar(1024) NULL, + column10 varchar(1024) NULL, + column11 varchar(1024) NULL, + column12 varchar(1024) NULL, + column13 varchar(1024) NULL, + column14 varchar(1024) NULL, + column15 varchar(1024) NULL, + column16 varchar(1024) NULL, + column17 varchar(1024) NULL, + column18 varchar(1024) NULL, + column19 varchar(1024) NULL, + column20 varchar(1024) NULL, + column21 varchar(1024) NULL, + column22 varchar(1024) NULL, + column23 varchar(1024) NULL, + column24 varchar(1024) NULL, + column25 varchar(1024) NULL, + column26 varchar(1024) NULL, + column27 varchar(1024) NULL, + column28 varchar(1024) NULL, + column29 varchar(1024) NULL, + column30 varchar(1024) NULL, + column31 varchar(1024) NULL, + column32 varchar(1024) NULL, + column33 varchar(1024) NULL, + column34 varchar(1024) NULL, + column35 varchar(1024) NULL, + column36 varchar(1024) NULL, + column37 varchar(1024) NULL, + column38 varchar(1024) NULL, + column39 varchar(1024) NULL, + column40 varchar(1024) NULL, + column41 varchar(1024) NULL, + column42 varchar(1024) NULL, + column43 varchar(1024) NULL, + column44 varchar(1024) NULL, + column45 varchar(1024) NULL, + column46 varchar(1024) NULL, + column47 varchar(1024) NULL, + column48 varchar(1024) NULL, + column49 varchar(1024) NULL, + column50 varchar(1024) NULL, + column51 varchar(1024) NULL, + column52 varchar(1024) NULL, + column53 varchar(1024) NULL, + is_rownumber_fetched int4 null, + create_time timestamp DEFAULT current_timestamp +); + + + + +create TABLE mmt_staging2.stg_process_table_PTO_PHA ( + generic_syspk int, + file_syspk bigint, + file_name varchar(1024) NULL, + file_date date NULL, + file_format varchar(1024) NULL, + sheet_number int4 NULL, + sheet_name varchar(1024) NULL, + sheet_format text, + sheet_mnemonic varchar(1024) NULL, + row_number int4 NULL, + file_creation_date timestamp NULL, + column1 varchar(1024) NULL, + column2 varchar(1024) NULL, + column3 varchar(1024) NULL, + column4 varchar(1024) NULL, + column5 varchar(1024) NULL, + column6 varchar(1024) NULL, + column7 varchar(1024) NULL, + column8 varchar(1024) NULL, + column9 varchar(1024) NULL, + column10 varchar(1024) NULL, + column11 varchar(1024) NULL, + column12 varchar(1024) NULL, + column13 varchar(1024) NULL, + column14 varchar(1024) NULL, + column15 varchar(1024) NULL, + column16 varchar(1024) NULL, + column17 varchar(1024) NULL, + column18 varchar(1024) NULL, + column19 varchar(1024) NULL, + column20 varchar(1024) NULL, + column21 varchar(1024) NULL, + column22 varchar(1024) NULL, + column23 varchar(1024) NULL, + column24 varchar(1024) NULL, + column25 varchar(1024) NULL, + column26 varchar(1024) NULL, + column27 varchar(1024) NULL, + column28 varchar(1024) NULL, + column29 varchar(1024) NULL, + column30 varchar(1024) NULL, + column31 varchar(1024) NULL, + column32 varchar(1024) NULL, + column33 varchar(1024) NULL, + column34 varchar(1024) NULL, + column35 varchar(1024) NULL, + column36 varchar(1024) NULL, + column37 varchar(1024) NULL, + column38 varchar(1024) NULL, + column39 varchar(1024) NULL, + column40 varchar(1024) NULL, + column41 varchar(1024) NULL, + column42 varchar(1024) NULL, + column43 varchar(1024) NULL, + column44 varchar(1024) NULL, + column45 varchar(1024) NULL, + column46 varchar(1024) NULL, + column47 varchar(1024) NULL, + column48 varchar(1024) NULL, + column49 varchar(1024) NULL, + column50 varchar(1024) NULL, + column51 varchar(1024) NULL, + column52 varchar(1024) NULL, + column53 varchar(1024) NULL, + is_rownumber_fetched int4 NULL, + create_time timestamp DEFAULT current_timestamp, + rank int4 NULL, + rank_tag text null +); + + + +CREATE TABLE mmt_staging2.stg_specific_table_PTO_PHA ( + generic_syspk int, + file_syspk bigint, + file_name varchar(1024) NULL, + file_date date NULL, + file_format varchar(1024) NULL, + sheet_number int4 NULL, + sheet_name varchar(1024) NULL, + sheet_format text, + sheet_mnemonic varchar(1024) NULL, + row_number int4 NULL, + file_creation_date timestamp NULL, + column1 varchar(1024) NULL, + column2 varchar(1024) NULL, + column3 varchar(1024) NULL, + column4 varchar(1024) NULL, + column5 varchar(1024) NULL, + column6 varchar(1024) NULL, + column7 varchar(1024) NULL, + column8 varchar(1024) NULL, + column9 varchar(1024) NULL, + column10 varchar(1024) NULL, + column11 varchar(1024) NULL, + column12 varchar(1024) NULL, + column13 varchar(1024) NULL, + column14 varchar(1024) NULL, + column15 varchar(1024) NULL, + column16 varchar(1024) NULL, + column17 varchar(1024) NULL, + column18 varchar(1024) NULL, + column19 varchar(1024) NULL, + column20 varchar(1024) NULL, + column21 varchar(1024) NULL, + column22 varchar(1024) NULL, + column23 varchar(1024) NULL, + column24 varchar(1024) NULL, + column25 varchar(1024) NULL, + column26 varchar(1024) NULL, + column27 varchar(1024) NULL, + column28 varchar(1024) NULL, + column29 varchar(1024) NULL, + column30 varchar(1024) NULL, + column31 varchar(1024) NULL, + column32 varchar(1024) NULL, + column33 varchar(1024) NULL, + column34 varchar(1024) NULL, + column35 varchar(1024) NULL, + column36 varchar(1024) NULL, + column37 varchar(1024) NULL, + column38 varchar(1024) NULL, + column39 varchar(1024) NULL, + column40 varchar(1024) NULL, + column41 varchar(1024) NULL, + column42 varchar(1024) NULL, + column43 varchar(1024) NULL, + column44 varchar(1024) NULL, + column45 varchar(1024) NULL, + column46 varchar(1024) NULL, + column47 varchar(1024) NULL, + column48 varchar(1024) NULL, + column49 varchar(1024) NULL, + column50 varchar(1024) NULL, + column51 varchar(1024) NULL, + column52 varchar(1024) NULL, + column53 varchar(1024) NULL, + is_rownumber_fetched int4 null, + create_time timestamp DEFAULT current_timestamp +); + + + +create TABLE mmt_staging2.stg_process_table_PTO_MPM ( + generic_syspk int, + file_syspk bigint, + file_name varchar(1024) NULL, + file_date date NULL, + file_format varchar(1024) NULL, + sheet_number int4 NULL, + sheet_name varchar(1024) NULL, + sheet_format text, + sheet_mnemonic varchar(1024) NULL, + row_number int4 NULL, + file_creation_date timestamp NULL, + column1 varchar(1024) NULL, + column2 varchar(1024) NULL, + column3 varchar(1024) NULL, + column4 varchar(1024) NULL, + column5 varchar(1024) NULL, + column6 varchar(1024) NULL, + column7 varchar(1024) NULL, + column8 varchar(1024) NULL, + column9 varchar(1024) NULL, + column10 varchar(1024) NULL, + column11 varchar(1024) NULL, + column12 varchar(1024) NULL, + column13 varchar(1024) NULL, + column14 varchar(1024) NULL, + column15 varchar(1024) NULL, + column16 varchar(1024) NULL, + column17 varchar(1024) NULL, + column18 varchar(1024) NULL, + column19 varchar(1024) NULL, + column20 varchar(1024) NULL, + column21 varchar(1024) NULL, + column22 varchar(1024) NULL, + column23 varchar(1024) NULL, + column24 varchar(1024) NULL, + column25 varchar(1024) NULL, + column26 varchar(1024) NULL, + column27 varchar(1024) NULL, + column28 varchar(1024) NULL, + column29 varchar(1024) NULL, + column30 varchar(1024) NULL, + column31 varchar(1024) NULL, + column32 varchar(1024) NULL, + column33 varchar(1024) NULL, + column34 varchar(1024) NULL, + column35 varchar(1024) NULL, + column36 varchar(1024) NULL, + column37 varchar(1024) NULL, + column38 varchar(1024) NULL, + column39 varchar(1024) NULL, + column40 varchar(1024) NULL, + column41 varchar(1024) NULL, + column42 varchar(1024) NULL, + column43 varchar(1024) NULL, + column44 varchar(1024) NULL, + column45 varchar(1024) NULL, + column46 varchar(1024) NULL, + column47 varchar(1024) NULL, + column48 varchar(1024) NULL, + column49 varchar(1024) NULL, + column50 varchar(1024) NULL, + column51 varchar(1024) NULL, + column52 varchar(1024) NULL, + column53 varchar(1024) NULL, + is_rownumber_fetched int4 NULL, + create_time timestamp DEFAULT current_timestamp, + rank int4 NULL, + rank_tag text null +); + + + +CREATE TABLE mmt_staging2.stg_specific_table_PTO_MPM ( + generic_syspk int, + file_syspk bigint, + file_name varchar(1024) NULL, + file_date date NULL, + file_format varchar(1024) NULL, + sheet_number int4 NULL, + sheet_name varchar(1024) NULL, + sheet_format text, + sheet_mnemonic varchar(1024) NULL, + row_number int4 NULL, + file_creation_date timestamp NULL, + column1 varchar(1024) NULL, + column2 varchar(1024) NULL, + column3 varchar(1024) NULL, + column4 varchar(1024) NULL, + column5 varchar(1024) NULL, + column6 varchar(1024) NULL, + column7 varchar(1024) NULL, + column8 varchar(1024) NULL, + column9 varchar(1024) NULL, + column10 varchar(1024) NULL, + column11 varchar(1024) NULL, + column12 varchar(1024) NULL, + column13 varchar(1024) NULL, + column14 varchar(1024) NULL, + column15 varchar(1024) NULL, + column16 varchar(1024) NULL, + column17 varchar(1024) NULL, + column18 varchar(1024) NULL, + column19 varchar(1024) NULL, + column20 varchar(1024) NULL, + column21 varchar(1024) NULL, + column22 varchar(1024) NULL, + column23 varchar(1024) NULL, + column24 varchar(1024) NULL, + column25 varchar(1024) NULL, + column26 varchar(1024) NULL, + column27 varchar(1024) NULL, + column28 varchar(1024) NULL, + column29 varchar(1024) NULL, + column30 varchar(1024) NULL, + column31 varchar(1024) NULL, + column32 varchar(1024) NULL, + column33 varchar(1024) NULL, + column34 varchar(1024) NULL, + column35 varchar(1024) NULL, + column36 varchar(1024) NULL, + column37 varchar(1024) NULL, + column38 varchar(1024) NULL, + column39 varchar(1024) NULL, + column40 varchar(1024) NULL, + column41 varchar(1024) NULL, + column42 varchar(1024) NULL, + column43 varchar(1024) NULL, + column44 varchar(1024) NULL, + column45 varchar(1024) NULL, + column46 varchar(1024) NULL, + column47 varchar(1024) NULL, + column48 varchar(1024) NULL, + column49 varchar(1024) NULL, + column50 varchar(1024) NULL, + column51 varchar(1024) NULL, + column52 varchar(1024) NULL, + column53 varchar(1024) NULL, + is_rownumber_fetched int4 null, + create_time timestamp DEFAULT current_timestamp +); + + + +create TABLE mmt_staging2.stg_process_table_PTO_GVG ( + generic_syspk int, + file_syspk bigint, + file_name varchar(1024) NULL, + file_date date NULL, + file_format varchar(1024) NULL, + sheet_number int4 NULL, + sheet_name varchar(1024) NULL, + sheet_format text, + sheet_mnemonic varchar(1024) NULL, + row_number int4 NULL, + file_creation_date timestamp NULL, + column1 varchar(1024) NULL, + column2 varchar(1024) NULL, + column3 varchar(1024) NULL, + column4 varchar(1024) NULL, + column5 varchar(1024) NULL, + column6 varchar(1024) NULL, + column7 varchar(1024) NULL, + column8 varchar(1024) NULL, + column9 varchar(1024) NULL, + column10 varchar(1024) NULL, + column11 varchar(1024) NULL, + column12 varchar(1024) NULL, + column13 varchar(1024) NULL, + column14 varchar(1024) NULL, + column15 varchar(1024) NULL, + column16 varchar(1024) NULL, + column17 varchar(1024) NULL, + column18 varchar(1024) NULL, + column19 varchar(1024) NULL, + column20 varchar(1024) NULL, + column21 varchar(1024) NULL, + column22 varchar(1024) NULL, + column23 varchar(1024) NULL, + column24 varchar(1024) NULL, + column25 varchar(1024) NULL, + column26 varchar(1024) NULL, + column27 varchar(1024) NULL, + column28 varchar(1024) NULL, + column29 varchar(1024) NULL, + column30 varchar(1024) NULL, + column31 varchar(1024) NULL, + column32 varchar(1024) NULL, + column33 varchar(1024) NULL, + column34 varchar(1024) NULL, + column35 varchar(1024) NULL, + column36 varchar(1024) NULL, + column37 varchar(1024) NULL, + column38 varchar(1024) NULL, + column39 varchar(1024) NULL, + column40 varchar(1024) NULL, + column41 varchar(1024) NULL, + column42 varchar(1024) NULL, + column43 varchar(1024) NULL, + column44 varchar(1024) NULL, + column45 varchar(1024) NULL, + column46 varchar(1024) NULL, + column47 varchar(1024) NULL, + column48 varchar(1024) NULL, + column49 varchar(1024) NULL, + column50 varchar(1024) NULL, + column51 varchar(1024) NULL, + column52 varchar(1024) NULL, + column53 varchar(1024) NULL, + is_rownumber_fetched int4 NULL, + create_time timestamp DEFAULT current_timestamp, + rank int4 NULL, + rank_tag text null +); + + + +CREATE TABLE mmt_staging2.stg_specific_table_PTO_GVG ( + generic_syspk int, + file_syspk bigint, + file_name varchar(1024) NULL, + file_date date NULL, + file_format varchar(1024) NULL, + sheet_number int4 NULL, + sheet_name varchar(1024) NULL, + sheet_format text, + sheet_mnemonic varchar(1024) NULL, + row_number int4 NULL, + file_creation_date timestamp NULL, + column1 varchar(1024) NULL, + column2 varchar(1024) NULL, + column3 varchar(1024) NULL, + column4 varchar(1024) NULL, + column5 varchar(1024) NULL, + column6 varchar(1024) NULL, + column7 varchar(1024) NULL, + column8 varchar(1024) NULL, + column9 varchar(1024) NULL, + column10 varchar(1024) NULL, + column11 varchar(1024) NULL, + column12 varchar(1024) NULL, + column13 varchar(1024) NULL, + column14 varchar(1024) NULL, + column15 varchar(1024) NULL, + column16 varchar(1024) NULL, + column17 varchar(1024) NULL, + column18 varchar(1024) NULL, + column19 varchar(1024) NULL, + column20 varchar(1024) NULL, + column21 varchar(1024) NULL, + column22 varchar(1024) NULL, + column23 varchar(1024) NULL, + column24 varchar(1024) NULL, + column25 varchar(1024) NULL, + column26 varchar(1024) NULL, + column27 varchar(1024) NULL, + column28 varchar(1024) NULL, + column29 varchar(1024) NULL, + column30 varchar(1024) NULL, + column31 varchar(1024) NULL, + column32 varchar(1024) NULL, + column33 varchar(1024) NULL, + column34 varchar(1024) NULL, + column35 varchar(1024) NULL, + column36 varchar(1024) NULL, + column37 varchar(1024) NULL, + column38 varchar(1024) NULL, + column39 varchar(1024) NULL, + column40 varchar(1024) NULL, + column41 varchar(1024) NULL, + column42 varchar(1024) NULL, + column43 varchar(1024) NULL, + column44 varchar(1024) NULL, + column45 varchar(1024) NULL, + column46 varchar(1024) NULL, + column47 varchar(1024) NULL, + column48 varchar(1024) NULL, + column49 varchar(1024) NULL, + column50 varchar(1024) NULL, + column51 varchar(1024) NULL, + column52 varchar(1024) NULL, + column53 varchar(1024) NULL, + is_rownumber_fetched int4 null, + create_time timestamp DEFAULT current_timestamp +); \ No newline at end of file diff --git a/MMT_SQL/onetime/create_tables_trs_sum.sql b/MMT_SQL/onetime/create_tables_trs_sum.sql deleted file mode 100644 index 57d23ee..0000000 --- a/MMT_SQL/onetime/create_tables_trs_sum.sql +++ /dev/null @@ -1,1847 +0,0 @@ -/* create block tables */ - -select mmt_ods.fn_update_NA(); - -SET search_path TO mmt_staging2; - -drop table if exists mmt_staging2.FTDRY_TRS_H1_INT; - -drop table if exists mmt_staging2.ftdry_trs_h1_block ; - -drop table if exists mmt_staging2.ftdry_trs_implement_block ; - -drop table if exists mmt_staging2.ftdry_trs_spec_block; - -drop table if exists mmt_staging2.ftdry_trs_engine_rpm_block; - -drop table if exists mmt_staging2.FTWET_TRS_H1_INT; - -drop table if exists mmt_staging2.FTWET_TRS_H1_Block; - -drop table if exists mmt_staging2.FTWET_TRS_SPEC_Block; - -drop table if exists mmt_staging2.FTWET_TRS_Engine_RPM_Block; - -drop table if exists mmt_staging2.FTWET_TRS_Implement_Block; - -drop table if exists mmt_staging2.FTHLG_TRS_H1_INT; - -drop table if exists mmt_staging2.FTHLG_TRS_H1_Block; - -drop table if exists mmt_staging2.FTHLG_TRS_SPEC_Block; - -drop table if exists mmt_staging2.FTHLG_TRS_Engine_RPM_Block; - -drop table if exists mmt_staging2.FTHLG_TRS_Trailer_Block; - -drop table if exists mmt_staging2.FTHLG_SUM_Trac_H1_Block; - -drop table if exists mmt_staging2.FTHLG_SUM_Trail_Type_Block; - -drop table if exists mmt_staging2.FTHLG_SUM_Test_Condition_1_Block; - -drop table if exists mmt_staging2.FTHLG_SUM_Test_Condition_2_Block; - -drop table if exists mmt_staging2.FTHLG_SUM_Comments_By_Block; - -drop table if exists mmt_staging2.FTWET_SUM_Trac_H1_Block; - -drop table if exists mmt_staging2.FTWET_SUM_Implement_Block; - -drop table if exists mmt_staging2.FTWET_SUM_Cage_Wheel_Block; -; -drop table if exists mmt_staging2.FTWET_SUM_Test_Condition_Block; - -drop table if exists mmt_staging2.FTWET_SUM_Comments_By_Block; - -drop table if exists mmt_staging2.FTDRY_SUM_Trac_H1_Block; - -drop table if exists mmt_staging2.FTDRY_SUM_Implement_Block; - -drop table if exists mmt_staging2.FTDRY_SUM_Test_Condition_1_Block; - -drop table if exists mmt_staging2.FTDRY_SUM_Test_Condition_2_Block; - -drop table if exists mmt_staging2.FTDRY_SUM_Comments_By_Block; - -drop table if exists mmt_staging2.stg_process_table_ftdry_sum; - -drop table if exists mmt_staging2.stg_process_table_ftdry_trs; - -drop table if exists mmt_staging2.stg_process_table_fthlg_sum; - -drop table if exists mmt_staging2.stg_process_table_fthlg_trs; - -drop table if exists mmt_staging2.stg_process_table_ftwet_sum; - -drop table if exists mmt_staging2.stg_process_table_ftwet_trs; - -drop table if exists mmt_staging2.stg_specific_table_ftdry_sum; - -drop table if exists mmt_staging2.stg_specific_table_ftdry_trs; - -drop table if exists mmt_staging2.stg_specific_table_fthlg_sum; - -drop table if exists mmt_staging2.stg_specific_table_fthlg_trs; - -drop table if exists mmt_staging2.stg_specific_table_ftwet_sum; - -drop table if exists mmt_staging2.stg_specific_table_ftwet_trs; - - -/* TRS starts */ - - -/* FTDRY_TRS starts */ - -create table mmt_staging2.FTDRY_TRS_H1_INT -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -column2 text, -column3 text, -column4 text, -column5 text, -column6 text, -column7 text, -create_time timestamp DEFAULT current_timestamp -); - -create table mmt_staging2.FTDRY_TRS_H1_Block -( -syspk serial, -file_syspk int, -client_id int, -function_id int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Report_Reference_No text, -Objective_Of_Test text, -Background_of_Test text, -Job_Order_No text, -Test_Location text, -Soil_Moisture_Content_ text, -Soil_Bulk_Density_g_cc text, -Test_Engineer text, -Test_Operator text, -Date_of_Test text, -Report_Date text, -Season text, -Type_of_Soil text, -Soil_Cone_Index_kPa text, -Field_Condition text, -create_time timestamp DEFAULT current_timestamp -); - - - -create table mmt_staging2.FTDRY_TRS_SPEC_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Tractor_Model text, -Tractor_Make text, -Tractor_Sr_No text, -Tractor_Engine_HP text, -FIP_Type text, -hour_Meter_Reading text, -Steering_Type text, -Transmission_Type text, -Wheel_Drive_Type_WD text, -EGR_Yes_No text, -Brake_Type text, -PTO_Type text, -Standard_PTO_Speed_RPM text, -EPTO_Speed_RPM text, -Front_Tyre_Make text, -Front_Tyre_Size text, -Front_Tyre_Pressure_psi text, -Rear_Tyre_Make text, -Rear_Tyre_Size text, -Rear_Tyre_Pressure_psi text, -Tractor_Weight_kg_Front text, -Tractor_Weight_kg_Rear text, -Tractor_Weight_kg_Total text, -Ballasted_Tractor_Accessories text, -Mechanical_Ballast_Rear text, -Mechanical_Ballast_Rear_in_KG text, -Water_Ballast_Rear text, -Mechanical_Ballast_Front text, -Mechanical_Ballast_Front_in_Kg text, -Total_Ballast_Weight text, -create_time timestamp DEFAULT current_timestamp -); - - -create table mmt_staging2.FTDRY_TRS_Engine_RPM_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Tractor_model text, -Tractor_make text, -Low_Idle text, -High_Idle text, -Rated_RPM text, -Engine_to_PTO_Ratio_540_PTO text, -Engine_to_PTO_Ratio_540E_PTO text, -create_time timestamp DEFAULT current_timestamp -); - - -create table mmt_staging2.FTDRY_TRS_Implement_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Name_of_Implement text, -Type_of_Implement text, -Make_of_Implement text, -No_of_bottoms_Tyne_Disc_Blade text, -Cutting_Width_m text, -Implement_Weight_Kg text, -Hitch_Category text, -Span_cm_For_Mounted_Implement text, -Mast_Height_cm_For_Mounted_Implement text, -FDPD_TDC_Mar15_008 text, -create_time timestamp DEFAULT current_timestamp -); - -/* FTDRY_TRS ends */ - - -/* FTWET_TRS starts */ -create table mmt_staging2.FTWET_TRS_H1_INT -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -column2 text, -column3 text, -column4 text, -column5 text, -column6 text, -column7 text, -create_time timestamp DEFAULT current_timestamp -); - - -create table mmt_staging2.FTWET_TRS_H1_Block -( -syspk serial, -file_syspk int, -client_id int, -function_id int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Report_Reference_No text, -Objective_Of_Test text, -Background_of_Test text, -Job_Order_No text, -Test_Location text, -Soil_Moisture_Content_ text, -Soil_Bulk_Density_g_cc text, -Test_Engineer text, -Test_Operator text, -Date_of_Test text, -Report_Date text, -Season text, -Type_of_Soil text, -Soil_Cone_Index_kPa text, -Field_Condition text, -create_time timestamp DEFAULT current_timestamp -); - -create table mmt_staging2.FTWET_TRS_SPEC_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Tractor_Model text, -Tractor_Make text, -Tractor_Sr_No text, -Tractor_Engine_HP text, -FIP_Type text, -hour_Meter_Reading text, -Steering_Type text, -Transmission_Type text, -Wheel_Drive_Type_WD text, -EGR_Yes_No text, -Brake_Type text, -PTO_Type text, -Standard_PTO_Speed_RPM text, -EPTO_Speed_RPM text, -Front_Tyre_Make text, -Front_Tyre_Size text, -Front_Tyre_Pressure_psi text, -Rear_Tyre_Make text, -Rear_Tyre_Size text, -Rear_Tyre_Pressure_psi text, -Tractor_Weight_kg_Front text, -Tractor_Weight_kg_Rear text, -Tractor_Weight_kg_Total text, -Ballasted_Tractor_Accessories text, -Mechanical_Ballast_Rear_in_KG text, -Water_Ballast_Rear text, -Mechanical_Ballast_Front text, -Mechanical_Ballast_Front_in_Kg text, -Total_Ballast_Weight text, -create_time timestamp DEFAULT current_timestamp -); - - -create table mmt_staging2.FTWET_TRS_Engine_RPM_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Tractor_model text, -Tractor_make text, -Low_Idle text, -High_Idle text, -Rated_RPM text, -Engine_to_PTO_Ratio_540_PTO text, -Engine_to_PTO_Ratio_540E_PTO text, -create_time timestamp DEFAULT current_timestamp -); - - -create table mmt_staging2.FTWET_TRS_Implement_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Name_of_Implement text, -Type_of_Implement text, -Make_of_Implement text, -No_of_bottoms_Tyne_Disc_Blade text, -Cutting_Width_m text, -Implement_Weight_Kg text, -Hitch_Category text, -Span_cm_For_Mounted_Implement text, -Mast_Height_cm_For_Mounted_Implement text, -Type_of_Cage_Wheel_Half_Cage_wheel_Full_Cage_Wheel text, -Cage_Wheel_Width_mm text, -Cage_wheel_Weight text, -Cage_Wheel_inner_Outer_Ring_Dia_mm text, -Cage_Wheel_Center_Ring_Dia_mm text, -Distance_between_RHS_LHS_cage_wheel_Inner_Ring_mm_For_Full_Cage_wheel text, -No_of_angles_on_cage_wheel text, -No_of_days_of_water_logging text, -Depth_of_water_mm text, -FDPD_TDC_Mar15_008 text, -create_time timestamp DEFAULT current_timestamp -); - -/* FTWET_TRS ends */ - - -/*FTHLG_TRS starts*/ - -create table mmt_staging2.FTHLG_TRS_H1_INT -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -column2 text, -column3 text, -column4 text, -column5 text, -column6 text, -column7 text, -create_time timestamp DEFAULT current_timestamp -); - - -create table mmt_staging2.FTHLG_TRS_H1_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Report_Reference_No text, -Objective_Of_Test text, -Background_of_Test text, -Job_Order_No text, -Test_Location text, -Gradient_Slope_1_Degree text, -Gradient_Slope_2_Degree text, -Tractor_Hitch_Type text, -Test_Engineer text, -Test_Operator text, -Date_of_Test text, -Report_Date text, -Type_of_Road text, -Tractor_Hitch_Height_from_Ground_mm text, -Tractor_Rear_Wheel_Center_to_Hitch_Point_Center_Distance_mm text, -create_time timestamp DEFAULT current_timestamp -); - - - -create table mmt_staging2.FTHLG_TRS_SPEC_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Tractor_Model text, -Tractor_Make text, -Tractor_Sr_No text, -Tractor_Engine_HP text, -FIP_Type text, -Hour_Meter_Reading text, -Steering_Type text, -Transmission_Type text, -Wheel_Drive_Type_WD text, -EGR_Yes_No text, -Brake_Type text, -PTO_Type text, -Standard_PTO_Speed_RPM text, -EPTO_Speed_RPM text, -Front_Tyre_Make text, -Front_Tyre_Size text, -Front_Tyre_Pressure_psi text, -Rear_Tyre_Make text, -Rear_Tyre_Size text, -Rear_Tyre_Pressure_psi text, -Tractor_Weight_kg_Front text, -Tractor_Weight_kg_Rear text, -Tractor_Weight_kg_Total text, -Ballasted_Tractor_Accessories text, -Mechanical_Ballast_Rear text, -Mechanical_Ballast_Rear_in_kg text, -Water_Ballast_Rear_75 text, -Mechanical_Ballast_Front_in_kg text, -Mechanical_Ballast_Front text, -Total_Ballast_Weight text, -create_time timestamp DEFAULT current_timestamp -); - - -create table mmt_staging2.FTHLG_TRS_Engine_RPM_Block -( -syspk serial, -file_syspk int, -client_id int, -function_id int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Tractor_model text, -Tractor_make text, -Low_Idle text, -High_Idle text, -Rated_RPM text, -Engine_to_PTO_Ratio_540_PTO text, -Engine_to_PTO_Ratio_540E_PTO text, -create_time timestamp DEFAULT current_timestamp -); - - -create table mmt_staging2.FTHLG_TRS_Trailer_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Type_Of_Trailer text, -No_Of_Axle text, -No_Of_Wheels text, -Trailer_hitch_Height_above_ground_level_mm text, -Make_model_of_trailer text, -Trailer_platform_length_mm text, -Trailer_platform_Width_mm text, -Trailer_platform_Height_mm text, -Tire_size text, -Inflation_pressure_psi text, -Track_width_of_trailer_mm text, -Horizontal_distance_of_hitch_point_from_trailer_front_face_mm text, -Tractor_Rear_Wheel_Center_to_Hitch_Point_Center_Distance_mm text, -Distance_from_Trailerfront_axle_distance_from_hitch_point_mm text, -Distance_from_tractor_rear_wheel_center_to_tractor_rear_wheel_center_mm text, -Trailer_empty_weight_Kg text, -Trailer_Gross_Weight_Kg text, -FDPD_TDC_Mar15_009 text, -create_time timestamp DEFAULT current_timestamp -); - -/*FTHLG_TRS ends*/ - - -/* TRS ends*/ - - - -/* SUMMARY starts*/ - - -/*FTDRY_SUM starts*/ - -create table mmt_staging2.FTDRY_SUM_Trac_H1_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Tractor_Model text, -Tractor_Make text, -Tractor_Engine_HP text, -Rated_RPM text, -Transmission_Type text, -Wheel_Drive_Type text, -FIP_Type text, -Steering_Type text, -Tractor_Weight_kg_Front text, -Tractor_Weight_kg_Rear text, -Tractor_Weight_kg_Total text, -create_time timestamp DEFAULT current_timestamp -); - - - -create table mmt_staging2.FTDRY_SUM_Implement_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Make_of_Implement text, -Implement_Type text, -Implement_Size text, -Hitch_Category text, -Implement_Weight text, -Soil_Type text, -Moisture_Content text, -Bulk_Density_g_cc text, -Soil_Cone_index text, -Field_Condition text, -Season text, -create_time timestamp DEFAULT current_timestamp -); - -create table mmt_staging2.FTDRY_SUM_Test_Condition_1_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Test_Condition text, -Test_Date text, -Tractor_Model text, -Engine_RPM_set text, -PTO_RPM_set text, -Gear_Used text, -Nominal_Speed_KMPH text, -Engine_RPM_Drop_on_straight text, -Engine_RPM_Drop_on_turn text, -Depth_of_cut_cm text, -No_load_speed_kmph text, -On_load_speed_kmph text, -wheel_slippage_ text, -Fuel_consumption_lit_hr text, -Area_covered_acr_hr text, -Fuel_consumption_lit_Acr text, -M_M_Performance_in_compared_to_respective_competitor_tractors text, -Fuel_consumption_lit_hr_2 text, -Area_covered_acr_hr_2 text, -Fuel_consumption_lit_Acr_2 text, -Trail_Observations text, -Engine_Smoke_on_Load text, -Engine_acceleration_smoke text, -Draft_Response text, -Tractor_Steer_ability text, -Tractor_braking_performance text, -Front_Visibility text, -Implement_Accessibility text, -Front_Wheel_dragging_at_turning text, -Front_end_lifting_during_operation text, -RPM_Recovery_Time text, -Engine_Vibration text, -Engine_Sound text, -Implement_Lifting_Lowering_response text, -Pulverization_Quality text, -Pulverization_Index text, -create_time timestamp DEFAULT current_timestamp -); - - -create table mmt_staging2.FTDRY_SUM_Test_Condition_2_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Test_Condition text, -Test_Date text, -Tractor_Model text, -Engine_RPM_set text, -PTO_RPM_set text, -Gear_Used text, -Nominal_Speed_KMPH text, -Engine_RPM_Drop_on_straight text, -Engine_RPM_Drop_on_turn text, -Depth_of_cut_cm text, -No_load_speed_kmph text, -On_load_speed_kmph text, -wheel_slippage_ text, -Fuel_consumption_lit_hr text, -Area_covered_acr_hr text, -Fuel_consumption_lit_Acr text, -M_M_Performance_in_compared_to_respective_competitor_tractors text, -Fuel_consumption_lit_hr_2 text, -Area_covered_acr_hr_2 text, -Fuel_consumption_lit_Acr_2 text, -Trail_Observations text, -Engine_Smoke_on_Load text, -Engine_acceleration_smoke text, -Draft_Response text, -Tractor_Steer_ability text, -Tractor_braking_performance text, -Front_Visibility text, -Implement_Accessibility text, -Front_Wheel_dragging_at_turning text, -Front_end_lifting_during_operation text, -RPM_Recovery_Time text, -Engine_Vibration text, -Engine_Sound text, -Implement_Lifting_Lowering_response text, -Pulverization_Quality text, -Pulverization_Index text, -create_time timestamp DEFAULT current_timestamp -); - - -create table mmt_staging2.FTDRY_SUM_Comments_By_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Tractor_model text, -Test_Engineer_Comments_1 text, -Test_Manager_Comments_1 text, -Test_Engineer_Comments_2 text, -Test_Manager_Comments_2 text, -create_time timestamp DEFAULT current_timestamp -); - -/*FTDRY_SUM ends */ - - -/* FTWET_SUM starts */ - -create table mmt_staging2.FTWET_SUM_Trac_H1_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Tractor_Model text, -Tractor_Make text, -Tractor_Engine_HP text, -Rated_RPM text, -Transmission_Type text, -Wheel_Drive_Type text, -FIP_Type text, -Steering_Type text, -Tractor_Weight_kg_Front text, -Tractor_Weight_kg_Rear text, -Tractor_Weight_kg_Total text, -create_time timestamp DEFAULT current_timestamp -); - - -create table mmt_staging2.FTWET_SUM_Implement_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Make_of_Implement text, -Implement_Type text, -Implement_Size text, -Hitch_Category text, -Implement_Weight text, -Soil_Type text, -Moisture_Content text, -Bulk_Density_g_cc text, -Soil_Cone_index text, -Field_Condition text, -Season text, -create_time timestamp DEFAULT current_timestamp -); - -create table mmt_staging2.FTWET_SUM_Cage_Wheel_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Type_of_Cage_Wheel text, -Cage_Wheel_Width_mm text, -Cage_wheel_Weight text, -Cage_Wheel_inner_Outer_Ring_Dia_mm text, -Cage_Wheel_Center_Ring_Dia_mm text, -Distance_between_RHS_LHS_cage_wheel_Inner_Ring_mm text, -No_of_angles_on_cage_wheel text, -create_time timestamp DEFAULT current_timestamp -); - - -create table mmt_staging2.FTWET_SUM_Test_Condition_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Test_Condition text, -Test_Date text, -Tractor_Model text, -Engine_RPM_set text, -PTO_RPM_set text, -Gear_Used text, -Nominal_Speed_KMPH text, -Engine_RPM_Drop_on_straight_1st_Pass text, -Engine_RPM_Drop_on_straight_2nd_Pass text, -Engine_RPM_Drop_on_straight_3rd_Pass text, -Engine_RPM_Drop_on_turn_1st_Pass text, -Engine_RPM_Drop_on_turn_2nd_Pass text, -Engine_RPM_Drop_on_turn_3rd_Pass text, -No_of_passes text, -Avg_Depth_of_cut_cm text, -Fuel_consumption_lit_hr text, -Area_covered_acr_hr text, -Fuel_consumption_lit_Acr text, -M_M_Performance_in_compared_to_respective_competitor_tractors text, -Fuel_consumption_lit_hr_2 text, -Area_covered_acr_hr_2 text, -Fuel_consumption_lit_Acr_2 text, -Trail_Observations text, -Engine_Smoke_on_Load text, -Engine_acceleration_smoke text, -Draft_Response text, -Tractor_Steer_ability text, -Tractor_braking_performance text, -Front_Visibility text, -Implement_Accessibility text, -Front_Wheel_dragging_at_turning text, -Front_end_lifting_during_operation text, -RPM_Recovery_Time text, -Engine_Vibration text, -Engine_Sound text, -Implement_Lifting_Lowering_response text, -Pulverization_Quality text, -Pulverization_Index text, -create_time timestamp DEFAULT current_timestamp -); - - -create table mmt_staging2.FTWET_SUM_Comments_By_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Tractor_Model text, -Test_Manager_Comments text, -create_time timestamp DEFAULT current_timestamp -); - -/*FTWET_SUM ends */ - - -/*FTHLG_SUM starts*/ - -create table mmt_staging2.FTHLG_SUM_Trac_H1_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -tractor_model text, -tractor_make text, -tractor_engine_hp text, -rated_rpm text, -transmission_type text, -wheel_drive_type text, -fip_type text, -steering_type text, -tractor_weight_kg_front text, -tractor_weight_kg_rear text, -tractor_weight_kg_total text, -create_time timestamp DEFAULT current_timestamp -); - - - -create table mmt_staging2.FTHLG_SUM_Trail_Type_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Trailer_Type text, -Tire_size_and_inflation_pressure_psi text, -No_Of_Axle text, -No_Of_Wheels text, -Trailer_Gross_Weight_Kg text, -Tractor_Rear_Wheel_Center_to_Hitch_Point_Center_Distance_mm text, -Tractor_Hitch_Height_from_Ground_mm text, -Trailer_hitch_Height_above_ground_level_mm text, -Gradient_Slope_1_Degree text, -Gradient_Slope_2_degree text, -Tractor_Hitch_Type text -); - -create table mmt_staging2.FTHLG_SUM_Test_Condition_1_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Test_Condition text, -Test_Date text, -Tractor_Model text, -Fuel_consumption_Ltr_hr text, -Mileage_Km_Ltr text, -Average_speed_of_travel_kmph text, -Total_distance_travelled_km text, -Gear_used_on_Straight_Road text, -Straight_road_RPM_Drop text, -Gear_used_on_Up_Slope_1 text, -Up_Slope_RPM_Drop_1 text, -Gear_used_on_Up_Slope_2 text, -Up_Slope_RPM_Drop_2 text, -Gear_used_on_Down_Slope text, -Down_Slope_RPM_Shoot_up text, -M_M_Performance_compared_to_respective_competitor_tractors_is_better_and_is_poor_than_competitor text, -Fuel_consumption_lit_hr_2 text, -Mileage_Km_Ltr_2 text, -M_M_Performance_in_compared_to_respective_competitor_tractors text, -Fuel_consumption_lit_hr_3 text, -Mileage_Km_Ltr_3 text, -Engine_Smoke_on_Load text, -Engine_acceleration_smoke text, -Range_Gear_Shifting text, -Speed_Gear_Shifting text, -Tractor_Steer_ability text, -Tractor_braking_performance text, -Front_Visibility text, -Implement_Accessibility text, -Front_end_lifting_during_operation text, -RPM_Recovery_Time text, -Engine_Vibration text, -Engine_Sound text, -create_time timestamp DEFAULT current_timestamp -); - - -create table mmt_staging2.FTHLG_SUM_Test_Condition_2_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Test_Condition text, -Test_Date text, -Tractor_Model text, -Fuel_consumption_Ltr_hr text, -Mileage_Km_Ltr text, -Average_speed_of_travel_kmph text, -Total_distance_travelled_km text, -Gear_used_on_Straight_Road text, -Straight_road_RPM_Drop text, -Gear_used_on_Up_Slope_1 text, -Up_Slope_RPM_Drop_1 text, -Gear_used_on_Up_Slope_2 text, -Up_Slope_RPM_Drop_2 text, -Gear_used_on_Down_Slope text, -Down_Slope_RPM_Shoot_up text, -M_M_Performance_compared_to_respective_competitor_tractors_is_better_and_is_poor_than_competitor text, -Fuel_consumption_lit_hr_2 text, -Mileage_Km_Ltr_2 text, -M_M_Performance_in_compared_to_respective_competitor_tractors text, -Fuel_consumption_lit_hr_3 text, -Mileage_Km_Ltr_3 text, -Engine_Smoke_on_Load text, -Engine_acceleration_smoke text, -Range_Gear_Shifting text, -Speed_Gear_Shifting text, -Tractor_Steer_ability text, -Tractor_braking_performance text, -Front_Visibility text, -Implement_Accessibility text, -Front_end_lifting_during_operation text, -RPM_Recovery_Time text, -Engine_Vibration text, -Engine_Sound text, -create_time timestamp DEFAULT current_timestamp -); - - -create table mmt_staging2.FTHLG_SUM_Comments_By_Block -( -syspk serial, -client_id int, -function_id int, -file_syspk int, -file_format text, -sheet_mnemonic text, -dummy_f text, -Tractor_Model text, -Test_Engineer_Comments_1 text, -Test_Manager_Comments_1 text, -Test_Engineer_Comments_2 text, -Test_Manager_Comments_2 text, -create_time timestamp DEFAULT current_timestamp -); - - - -create TABLE mmt_staging2.stg_process_table_ftdry_trs ( - generic_syspk int, -file_syspk bigint, -file_name varchar(1024) NULL, -file_date date NULL, -file_format varchar(1024) NULL, -sheet_number int4 NULL, -sheet_name varchar(1024) NULL, -sheet_format text, -sheet_mnemonic varchar(1024) NULL, -row_number int4 NULL, -file_creation_date timestamp NULL, -column1 varchar(1024) NULL, -column2 varchar(1024) NULL, -column3 varchar(1024) NULL, -column4 varchar(1024) NULL, -column5 varchar(1024) NULL, -column6 varchar(1024) NULL, -column7 varchar(1024) NULL, -column8 varchar(1024) NULL, -column9 varchar(1024) NULL, -column10 varchar(1024) NULL, -column11 varchar(1024) NULL, -column12 varchar(1024) NULL, -column13 varchar(1024) NULL, -column14 varchar(1024) NULL, -column15 varchar(1024) NULL, -column16 varchar(1024) NULL, -column17 varchar(1024) NULL, -column18 varchar(1024) NULL, -column19 varchar(1024) NULL, -column20 varchar(1024) NULL, -column21 varchar(1024) NULL, -column22 varchar(1024) NULL, -column23 varchar(1024) NULL, -column24 varchar(1024) NULL, -column25 varchar(1024) NULL, -column26 varchar(1024) NULL, -column27 varchar(1024) NULL, -column28 varchar(1024) NULL, -column29 varchar(1024) NULL, -column30 varchar(1024) NULL, -column31 varchar(1024) NULL, -column32 varchar(1024) NULL, -column33 varchar(1024) NULL, -column34 varchar(1024) NULL, -column35 varchar(1024) NULL, -column36 varchar(1024) NULL, -column37 varchar(1024) NULL, -column38 varchar(1024) NULL, -column39 varchar(1024) NULL, -column40 varchar(1024) NULL, -column41 varchar(1024) NULL, -column42 varchar(1024) NULL, -column43 varchar(1024) NULL, -column44 varchar(1024) NULL, -column45 varchar(1024) NULL, -column46 varchar(1024) NULL, -column47 varchar(1024) NULL, -column48 varchar(1024) NULL, -column49 varchar(1024) NULL, -column50 varchar(1024) NULL, -column51 varchar(1024) NULL, -column52 varchar(1024) NULL, -column53 varchar(1024) NULL, -is_rownumber_fetched int4 NULL, -create_time timestamp DEFAULT current_timestamp, -rank int4 NULL, -rank_tag text null -); - - -CREATE TABLE mmt_staging2.stg_specific_table_ftdry_trs ( -generic_syspk int, -file_syspk bigint, -file_name varchar(1024) NULL, -file_date date NULL, -file_format varchar(1024) NULL, -sheet_number int4 NULL, -sheet_name varchar(1024) NULL, -sheet_format text, -sheet_mnemonic varchar(1024) NULL, -row_number int4 NULL, -file_creation_date timestamp NULL, -column1 varchar(1024) NULL, -column2 varchar(1024) NULL, -column3 varchar(1024) NULL, -column4 varchar(1024) NULL, -column5 varchar(1024) NULL, -column6 varchar(1024) NULL, -column7 varchar(1024) NULL, -column8 varchar(1024) NULL, -column9 varchar(1024) NULL, -column10 varchar(1024) NULL, -column11 varchar(1024) NULL, -column12 varchar(1024) NULL, -column13 varchar(1024) NULL, -column14 varchar(1024) NULL, -column15 varchar(1024) NULL, -column16 varchar(1024) NULL, -column17 varchar(1024) NULL, -column18 varchar(1024) NULL, -column19 varchar(1024) NULL, -column20 varchar(1024) NULL, -column21 varchar(1024) NULL, -column22 varchar(1024) NULL, -column23 varchar(1024) NULL, -column24 varchar(1024) NULL, -column25 varchar(1024) NULL, -column26 varchar(1024) NULL, -column27 varchar(1024) NULL, -column28 varchar(1024) NULL, -column29 varchar(1024) NULL, -column30 varchar(1024) NULL, -column31 varchar(1024) NULL, -column32 varchar(1024) NULL, -column33 varchar(1024) NULL, -column34 varchar(1024) NULL, -column35 varchar(1024) NULL, -column36 varchar(1024) NULL, -column37 varchar(1024) NULL, -column38 varchar(1024) NULL, -column39 varchar(1024) NULL, -column40 varchar(1024) NULL, -column41 varchar(1024) NULL, -column42 varchar(1024) NULL, -column43 varchar(1024) NULL, -column44 varchar(1024) NULL, -column45 varchar(1024) NULL, -column46 varchar(1024) NULL, -column47 varchar(1024) NULL, -column48 varchar(1024) NULL, -column49 varchar(1024) NULL, -column50 varchar(1024) NULL, -column51 varchar(1024) NULL, -column52 varchar(1024) NULL, -column53 varchar(1024) NULL, -is_rownumber_fetched int4 null, -create_time timestamp DEFAULT current_timestamp -); - - -create TABLE mmt_staging2.stg_process_table_ftwet_trs ( - generic_syspk int, -file_syspk bigint, -file_name varchar(1024) NULL, -file_date date NULL, -file_format varchar(1024) NULL, -sheet_number int4 NULL, -sheet_name varchar(1024) NULL, -sheet_format text, -sheet_mnemonic varchar(1024) NULL, -row_number int4 NULL, -file_creation_date timestamp NULL, -column1 varchar(1024) NULL, -column2 varchar(1024) NULL, -column3 varchar(1024) NULL, -column4 varchar(1024) NULL, -column5 varchar(1024) NULL, -column6 varchar(1024) NULL, -column7 varchar(1024) NULL, -column8 varchar(1024) NULL, -column9 varchar(1024) NULL, -column10 varchar(1024) NULL, -column11 varchar(1024) NULL, -column12 varchar(1024) NULL, -column13 varchar(1024) NULL, -column14 varchar(1024) NULL, -column15 varchar(1024) NULL, -column16 varchar(1024) NULL, -column17 varchar(1024) NULL, -column18 varchar(1024) NULL, -column19 varchar(1024) NULL, -column20 varchar(1024) NULL, -column21 varchar(1024) NULL, -column22 varchar(1024) NULL, -column23 varchar(1024) NULL, -column24 varchar(1024) NULL, -column25 varchar(1024) NULL, -column26 varchar(1024) NULL, -column27 varchar(1024) NULL, -column28 varchar(1024) NULL, -column29 varchar(1024) NULL, -column30 varchar(1024) NULL, -column31 varchar(1024) NULL, -column32 varchar(1024) NULL, -column33 varchar(1024) NULL, -column34 varchar(1024) NULL, -column35 varchar(1024) NULL, -column36 varchar(1024) NULL, -column37 varchar(1024) NULL, -column38 varchar(1024) NULL, -column39 varchar(1024) NULL, -column40 varchar(1024) NULL, -column41 varchar(1024) NULL, -column42 varchar(1024) NULL, -column43 varchar(1024) NULL, -column44 varchar(1024) NULL, -column45 varchar(1024) NULL, -column46 varchar(1024) NULL, -column47 varchar(1024) NULL, -column48 varchar(1024) NULL, -column49 varchar(1024) NULL, -column50 varchar(1024) NULL, -column51 varchar(1024) NULL, -column52 varchar(1024) NULL, -column53 varchar(1024) NULL, -is_rownumber_fetched int4 NULL, -create_time timestamp DEFAULT current_timestamp, -rank int4 NULL, -rank_tag text null -); - - -CREATE TABLE mmt_staging2.stg_specific_table_ftwet_trs ( - generic_syspk int, -file_syspk bigint, -file_name varchar(1024) NULL, -file_date date NULL, -file_format varchar(1024) NULL, -sheet_number int4 NULL, -sheet_name varchar(1024) NULL, -sheet_format text, -sheet_mnemonic varchar(1024) NULL, -row_number int4 NULL, -file_creation_date timestamp NULL, -column1 varchar(1024) NULL, -column2 varchar(1024) NULL, -column3 varchar(1024) NULL, -column4 varchar(1024) NULL, -column5 varchar(1024) NULL, -column6 varchar(1024) NULL, -column7 varchar(1024) NULL, -column8 varchar(1024) NULL, -column9 varchar(1024) NULL, -column10 varchar(1024) NULL, -column11 varchar(1024) NULL, -column12 varchar(1024) NULL, -column13 varchar(1024) NULL, -column14 varchar(1024) NULL, -column15 varchar(1024) NULL, -column16 varchar(1024) NULL, -column17 varchar(1024) NULL, -column18 varchar(1024) NULL, -column19 varchar(1024) NULL, -column20 varchar(1024) NULL, -column21 varchar(1024) NULL, -column22 varchar(1024) NULL, -column23 varchar(1024) NULL, -column24 varchar(1024) NULL, -column25 varchar(1024) NULL, -column26 varchar(1024) NULL, -column27 varchar(1024) NULL, -column28 varchar(1024) NULL, -column29 varchar(1024) NULL, -column30 varchar(1024) NULL, -column31 varchar(1024) NULL, -column32 varchar(1024) NULL, -column33 varchar(1024) NULL, -column34 varchar(1024) NULL, -column35 varchar(1024) NULL, -column36 varchar(1024) NULL, -column37 varchar(1024) NULL, -column38 varchar(1024) NULL, -column39 varchar(1024) NULL, -column40 varchar(1024) NULL, -column41 varchar(1024) NULL, -column42 varchar(1024) NULL, -column43 varchar(1024) NULL, -column44 varchar(1024) NULL, -column45 varchar(1024) NULL, -column46 varchar(1024) NULL, -column47 varchar(1024) NULL, -column48 varchar(1024) NULL, -column49 varchar(1024) NULL, -column50 varchar(1024) NULL, -column51 varchar(1024) NULL, -column52 varchar(1024) NULL, -column53 varchar(1024) NULL, -is_rownumber_fetched int4 null, -create_time timestamp DEFAULT current_timestamp -); - - -create TABLE mmt_staging2.stg_process_table_fthlg_trs ( - generic_syspk int, -file_syspk bigint, -file_name varchar(1024) NULL, -file_date date NULL, -file_format varchar(1024) NULL, -sheet_number int4 NULL, -sheet_name varchar(1024) NULL, -sheet_format text, -sheet_mnemonic varchar(1024) NULL, -row_number int4 NULL, -file_creation_date timestamp NULL, -column1 varchar(1024) NULL, -column2 varchar(1024) NULL, -column3 varchar(1024) NULL, -column4 varchar(1024) NULL, -column5 varchar(1024) NULL, -column6 varchar(1024) NULL, -column7 varchar(1024) NULL, -column8 varchar(1024) NULL, -column9 varchar(1024) NULL, -column10 varchar(1024) NULL, -column11 varchar(1024) NULL, -column12 varchar(1024) NULL, -column13 varchar(1024) NULL, -column14 varchar(1024) NULL, -column15 varchar(1024) NULL, -column16 varchar(1024) NULL, -column17 varchar(1024) NULL, -column18 varchar(1024) NULL, -column19 varchar(1024) NULL, -column20 varchar(1024) NULL, -column21 varchar(1024) NULL, -column22 varchar(1024) NULL, -column23 varchar(1024) NULL, -column24 varchar(1024) NULL, -column25 varchar(1024) NULL, -column26 varchar(1024) NULL, -column27 varchar(1024) NULL, -column28 varchar(1024) NULL, -column29 varchar(1024) NULL, -column30 varchar(1024) NULL, -column31 varchar(1024) NULL, -column32 varchar(1024) NULL, -column33 varchar(1024) NULL, -column34 varchar(1024) NULL, -column35 varchar(1024) NULL, -column36 varchar(1024) NULL, -column37 varchar(1024) NULL, -column38 varchar(1024) NULL, -column39 varchar(1024) NULL, -column40 varchar(1024) NULL, -column41 varchar(1024) NULL, -column42 varchar(1024) NULL, -column43 varchar(1024) NULL, -column44 varchar(1024) NULL, -column45 varchar(1024) NULL, -column46 varchar(1024) NULL, -column47 varchar(1024) NULL, -column48 varchar(1024) NULL, -column49 varchar(1024) NULL, -column50 varchar(1024) NULL, -column51 varchar(1024) NULL, -column52 varchar(1024) NULL, -column53 varchar(1024) NULL, -is_rownumber_fetched int4 NULL, -create_time timestamp DEFAULT current_timestamp, -rank int4 NULL, -rank_tag text null -); - - -CREATE TABLE mmt_staging2.stg_specific_table_fthlg_trs ( - generic_syspk int, -file_syspk bigint, -file_name varchar(1024) NULL, -file_date date NULL, -file_format varchar(1024) NULL, -sheet_number int4 NULL, -sheet_name varchar(1024) NULL, -sheet_format text, -sheet_mnemonic varchar(1024) NULL, -row_number int4 NULL, -file_creation_date timestamp NULL, -column1 varchar(1024) NULL, -column2 varchar(1024) NULL, -column3 varchar(1024) NULL, -column4 varchar(1024) NULL, -column5 varchar(1024) NULL, -column6 varchar(1024) NULL, -column7 varchar(1024) NULL, -column8 varchar(1024) NULL, -column9 varchar(1024) NULL, -column10 varchar(1024) NULL, -column11 varchar(1024) NULL, -column12 varchar(1024) NULL, -column13 varchar(1024) NULL, -column14 varchar(1024) NULL, -column15 varchar(1024) NULL, -column16 varchar(1024) NULL, -column17 varchar(1024) NULL, -column18 varchar(1024) NULL, -column19 varchar(1024) NULL, -column20 varchar(1024) NULL, -column21 varchar(1024) NULL, -column22 varchar(1024) NULL, -column23 varchar(1024) NULL, -column24 varchar(1024) NULL, -column25 varchar(1024) NULL, -column26 varchar(1024) NULL, -column27 varchar(1024) NULL, -column28 varchar(1024) NULL, -column29 varchar(1024) NULL, -column30 varchar(1024) NULL, -column31 varchar(1024) NULL, -column32 varchar(1024) NULL, -column33 varchar(1024) NULL, -column34 varchar(1024) NULL, -column35 varchar(1024) NULL, -column36 varchar(1024) NULL, -column37 varchar(1024) NULL, -column38 varchar(1024) NULL, -column39 varchar(1024) NULL, -column40 varchar(1024) NULL, -column41 varchar(1024) NULL, -column42 varchar(1024) NULL, -column43 varchar(1024) NULL, -column44 varchar(1024) NULL, -column45 varchar(1024) NULL, -column46 varchar(1024) NULL, -column47 varchar(1024) NULL, -column48 varchar(1024) NULL, -column49 varchar(1024) NULL, -column50 varchar(1024) NULL, -column51 varchar(1024) NULL, -column52 varchar(1024) NULL, -column53 varchar(1024) NULL, -is_rownumber_fetched int4 null, -create_time timestamp DEFAULT current_timestamp -); - - -create TABLE mmt_staging2.stg_process_table_ftdry_sum ( - generic_syspk int, -file_syspk bigint, -file_name varchar(1024) NULL, -file_date date NULL, -file_format varchar(1024) NULL, -sheet_number int4 NULL, -sheet_name varchar(1024) NULL, -sheet_format text, -sheet_mnemonic varchar(1024) NULL, -row_number int4 NULL, -file_creation_date timestamp NULL, -column1 varchar(1024) NULL, -column2 varchar(1024) NULL, -column3 varchar(1024) NULL, -column4 varchar(1024) NULL, -column5 varchar(1024) NULL, -column6 varchar(1024) NULL, -column7 varchar(1024) NULL, -column8 varchar(1024) NULL, -column9 varchar(1024) NULL, -column10 varchar(1024) NULL, -column11 varchar(1024) NULL, -column12 varchar(1024) NULL, -column13 varchar(1024) NULL, -column14 varchar(1024) NULL, -column15 varchar(1024) NULL, -column16 varchar(1024) NULL, -column17 varchar(1024) NULL, -column18 varchar(1024) NULL, -column19 varchar(1024) NULL, -column20 varchar(1024) NULL, -column21 varchar(1024) NULL, -column22 varchar(1024) NULL, -column23 varchar(1024) NULL, -column24 varchar(1024) NULL, -column25 varchar(1024) NULL, -column26 varchar(1024) NULL, -column27 varchar(1024) NULL, -column28 varchar(1024) NULL, -column29 varchar(1024) NULL, -column30 varchar(1024) NULL, -column31 varchar(1024) NULL, -column32 varchar(1024) NULL, -column33 varchar(1024) NULL, -column34 varchar(1024) NULL, -column35 varchar(1024) NULL, -column36 varchar(1024) NULL, -column37 varchar(1024) NULL, -column38 varchar(1024) NULL, -column39 varchar(1024) NULL, -column40 varchar(1024) NULL, -column41 varchar(1024) NULL, -column42 varchar(1024) NULL, -column43 varchar(1024) NULL, -column44 varchar(1024) NULL, -column45 varchar(1024) NULL, -column46 varchar(1024) NULL, -column47 varchar(1024) NULL, -column48 varchar(1024) NULL, -column49 varchar(1024) NULL, -column50 varchar(1024) NULL, -column51 varchar(1024) NULL, -column52 varchar(1024) NULL, -column53 varchar(1024) NULL, -is_rownumber_fetched int4 NULL, -create_time timestamp DEFAULT current_timestamp, -rank int4 NULL, -rank_tag text null -); - - -CREATE TABLE mmt_staging2.stg_specific_table_ftdry_sum ( - generic_syspk int, -file_syspk bigint, -file_name varchar(1024) NULL, -file_date date NULL, -file_format varchar(1024) NULL, -sheet_number int4 NULL, -sheet_name varchar(1024) NULL, -sheet_format text, -sheet_mnemonic varchar(1024) NULL, -row_number int4 NULL, -file_creation_date timestamp NULL, -column1 varchar(1024) NULL, -column2 varchar(1024) NULL, -column3 varchar(1024) NULL, -column4 varchar(1024) NULL, -column5 varchar(1024) NULL, -column6 varchar(1024) NULL, -column7 varchar(1024) NULL, -column8 varchar(1024) NULL, -column9 varchar(1024) NULL, -column10 varchar(1024) NULL, -column11 varchar(1024) NULL, -column12 varchar(1024) NULL, -column13 varchar(1024) NULL, -column14 varchar(1024) NULL, -column15 varchar(1024) NULL, -column16 varchar(1024) NULL, -column17 varchar(1024) NULL, -column18 varchar(1024) NULL, -column19 varchar(1024) NULL, -column20 varchar(1024) NULL, -column21 varchar(1024) NULL, -column22 varchar(1024) NULL, -column23 varchar(1024) NULL, -column24 varchar(1024) NULL, -column25 varchar(1024) NULL, -column26 varchar(1024) NULL, -column27 varchar(1024) NULL, -column28 varchar(1024) NULL, -column29 varchar(1024) NULL, -column30 varchar(1024) NULL, -column31 varchar(1024) NULL, -column32 varchar(1024) NULL, -column33 varchar(1024) NULL, -column34 varchar(1024) NULL, -column35 varchar(1024) NULL, -column36 varchar(1024) NULL, -column37 varchar(1024) NULL, -column38 varchar(1024) NULL, -column39 varchar(1024) NULL, -column40 varchar(1024) NULL, -column41 varchar(1024) NULL, -column42 varchar(1024) NULL, -column43 varchar(1024) NULL, -column44 varchar(1024) NULL, -column45 varchar(1024) NULL, -column46 varchar(1024) NULL, -column47 varchar(1024) NULL, -column48 varchar(1024) NULL, -column49 varchar(1024) NULL, -column50 varchar(1024) NULL, -column51 varchar(1024) NULL, -column52 varchar(1024) NULL, -column53 varchar(1024) NULL, -is_rownumber_fetched int4 null, -create_time timestamp DEFAULT current_timestamp -); - - - -create TABLE mmt_staging2.stg_process_table_ftwet_sum ( - generic_syspk int, -file_syspk bigint, -file_name varchar(1024) NULL, -file_date date NULL, -file_format varchar(1024) NULL, -sheet_number int4 NULL, -sheet_name varchar(1024) NULL, -sheet_format text, -sheet_mnemonic varchar(1024) NULL, -row_number int4 NULL, -file_creation_date timestamp NULL, -column1 varchar(1024) NULL, -column2 varchar(1024) NULL, -column3 varchar(1024) NULL, -column4 varchar(1024) NULL, -column5 varchar(1024) NULL, -column6 varchar(1024) NULL, -column7 varchar(1024) NULL, -column8 varchar(1024) NULL, -column9 varchar(1024) NULL, -column10 varchar(1024) NULL, -column11 varchar(1024) NULL, -column12 varchar(1024) NULL, -column13 varchar(1024) NULL, -column14 varchar(1024) NULL, -column15 varchar(1024) NULL, -column16 varchar(1024) NULL, -column17 varchar(1024) NULL, -column18 varchar(1024) NULL, -column19 varchar(1024) NULL, -column20 varchar(1024) NULL, -column21 varchar(1024) NULL, -column22 varchar(1024) NULL, -column23 varchar(1024) NULL, -column24 varchar(1024) NULL, -column25 varchar(1024) NULL, -column26 varchar(1024) NULL, -column27 varchar(1024) NULL, -column28 varchar(1024) NULL, -column29 varchar(1024) NULL, -column30 varchar(1024) NULL, -column31 varchar(1024) NULL, -column32 varchar(1024) NULL, -column33 varchar(1024) NULL, -column34 varchar(1024) NULL, -column35 varchar(1024) NULL, -column36 varchar(1024) NULL, -column37 varchar(1024) NULL, -column38 varchar(1024) NULL, -column39 varchar(1024) NULL, -column40 varchar(1024) NULL, -column41 varchar(1024) NULL, -column42 varchar(1024) NULL, -column43 varchar(1024) NULL, -column44 varchar(1024) NULL, -column45 varchar(1024) NULL, -column46 varchar(1024) NULL, -column47 varchar(1024) NULL, -column48 varchar(1024) NULL, -column49 varchar(1024) NULL, -column50 varchar(1024) NULL, -column51 varchar(1024) NULL, -column52 varchar(1024) NULL, -column53 varchar(1024) NULL, -is_rownumber_fetched int4 NULL, -create_time timestamp DEFAULT current_timestamp, -rank int4 NULL, -rank_tag text null -); - - -CREATE TABLE mmt_staging2.stg_specific_table_ftwet_sum ( - generic_syspk int, -file_syspk bigint, -file_name varchar(1024) NULL, -file_date date NULL, -file_format varchar(1024) NULL, -sheet_number int4 NULL, -sheet_name varchar(1024) NULL, -sheet_format text, -sheet_mnemonic varchar(1024) NULL, -row_number int4 NULL, -file_creation_date timestamp NULL, -column1 varchar(1024) NULL, -column2 varchar(1024) NULL, -column3 varchar(1024) NULL, -column4 varchar(1024) NULL, -column5 varchar(1024) NULL, -column6 varchar(1024) NULL, -column7 varchar(1024) NULL, -column8 varchar(1024) NULL, -column9 varchar(1024) NULL, -column10 varchar(1024) NULL, -column11 varchar(1024) NULL, -column12 varchar(1024) NULL, -column13 varchar(1024) NULL, -column14 varchar(1024) NULL, -column15 varchar(1024) NULL, -column16 varchar(1024) NULL, -column17 varchar(1024) NULL, -column18 varchar(1024) NULL, -column19 varchar(1024) NULL, -column20 varchar(1024) NULL, -column21 varchar(1024) NULL, -column22 varchar(1024) NULL, -column23 varchar(1024) NULL, -column24 varchar(1024) NULL, -column25 varchar(1024) NULL, -column26 varchar(1024) NULL, -column27 varchar(1024) NULL, -column28 varchar(1024) NULL, -column29 varchar(1024) NULL, -column30 varchar(1024) NULL, -column31 varchar(1024) NULL, -column32 varchar(1024) NULL, -column33 varchar(1024) NULL, -column34 varchar(1024) NULL, -column35 varchar(1024) NULL, -column36 varchar(1024) NULL, -column37 varchar(1024) NULL, -column38 varchar(1024) NULL, -column39 varchar(1024) NULL, -column40 varchar(1024) NULL, -column41 varchar(1024) NULL, -column42 varchar(1024) NULL, -column43 varchar(1024) NULL, -column44 varchar(1024) NULL, -column45 varchar(1024) NULL, -column46 varchar(1024) NULL, -column47 varchar(1024) NULL, -column48 varchar(1024) NULL, -column49 varchar(1024) NULL, -column50 varchar(1024) NULL, -column51 varchar(1024) NULL, -column52 varchar(1024) NULL, -column53 varchar(1024) NULL, -is_rownumber_fetched int4 null, -create_time timestamp DEFAULT current_timestamp -); - - -create TABLE mmt_staging2.stg_process_table_fthlg_sum ( - generic_syspk int, -file_syspk bigint, -file_name varchar(1024) NULL, -file_date date NULL, -file_format varchar(1024) NULL, -sheet_number int4 NULL, -sheet_name varchar(1024) NULL, -sheet_format text, -sheet_mnemonic varchar(1024) NULL, -row_number int4 NULL, -file_creation_date timestamp NULL, -column1 varchar(1024) NULL, -column2 varchar(1024) NULL, -column3 varchar(1024) NULL, -column4 varchar(1024) NULL, -column5 varchar(1024) NULL, -column6 varchar(1024) NULL, -column7 varchar(1024) NULL, -column8 varchar(1024) NULL, -column9 varchar(1024) NULL, -column10 varchar(1024) NULL, -column11 varchar(1024) NULL, -column12 varchar(1024) NULL, -column13 varchar(1024) NULL, -column14 varchar(1024) NULL, -column15 varchar(1024) NULL, -column16 varchar(1024) NULL, -column17 varchar(1024) NULL, -column18 varchar(1024) NULL, -column19 varchar(1024) NULL, -column20 varchar(1024) NULL, -column21 varchar(1024) NULL, -column22 varchar(1024) NULL, -column23 varchar(1024) NULL, -column24 varchar(1024) NULL, -column25 varchar(1024) NULL, -column26 varchar(1024) NULL, -column27 varchar(1024) NULL, -column28 varchar(1024) NULL, -column29 varchar(1024) NULL, -column30 varchar(1024) NULL, -column31 varchar(1024) NULL, -column32 varchar(1024) NULL, -column33 varchar(1024) NULL, -column34 varchar(1024) NULL, -column35 varchar(1024) NULL, -column36 varchar(1024) NULL, -column37 varchar(1024) NULL, -column38 varchar(1024) NULL, -column39 varchar(1024) NULL, -column40 varchar(1024) NULL, -column41 varchar(1024) NULL, -column42 varchar(1024) NULL, -column43 varchar(1024) NULL, -column44 varchar(1024) NULL, -column45 varchar(1024) NULL, -column46 varchar(1024) NULL, -column47 varchar(1024) NULL, -column48 varchar(1024) NULL, -column49 varchar(1024) NULL, -column50 varchar(1024) NULL, -column51 varchar(1024) NULL, -column52 varchar(1024) NULL, -column53 varchar(1024) NULL, -is_rownumber_fetched int4 NULL, -create_time timestamp DEFAULT current_timestamp, -rank int4 NULL, -rank_tag text null -); - - -CREATE TABLE mmt_staging2.stg_specific_table_fthlg_sum ( - generic_syspk int, -file_syspk bigint, -file_name varchar(1024) NULL, -file_date date NULL, -file_format varchar(1024) NULL, -sheet_number int4 NULL, -sheet_name varchar(1024) NULL, -sheet_format text, -sheet_mnemonic varchar(1024) NULL, -row_number int4 NULL, -file_creation_date timestamp NULL, -column1 varchar(1024) NULL, -column2 varchar(1024) NULL, -column3 varchar(1024) NULL, -column4 varchar(1024) NULL, -column5 varchar(1024) NULL, -column6 varchar(1024) NULL, -column7 varchar(1024) NULL, -column8 varchar(1024) NULL, -column9 varchar(1024) NULL, -column10 varchar(1024) NULL, -column11 varchar(1024) NULL, -column12 varchar(1024) NULL, -column13 varchar(1024) NULL, -column14 varchar(1024) NULL, -column15 varchar(1024) NULL, -column16 varchar(1024) NULL, -column17 varchar(1024) NULL, -column18 varchar(1024) NULL, -column19 varchar(1024) NULL, -column20 varchar(1024) NULL, -column21 varchar(1024) NULL, -column22 varchar(1024) NULL, -column23 varchar(1024) NULL, -column24 varchar(1024) NULL, -column25 varchar(1024) NULL, -column26 varchar(1024) NULL, -column27 varchar(1024) NULL, -column28 varchar(1024) NULL, -column29 varchar(1024) NULL, -column30 varchar(1024) NULL, -column31 varchar(1024) NULL, -column32 varchar(1024) NULL, -column33 varchar(1024) NULL, -column34 varchar(1024) NULL, -column35 varchar(1024) NULL, -column36 varchar(1024) NULL, -column37 varchar(1024) NULL, -column38 varchar(1024) NULL, -column39 varchar(1024) NULL, -column40 varchar(1024) NULL, -column41 varchar(1024) NULL, -column42 varchar(1024) NULL, -column43 varchar(1024) NULL, -column44 varchar(1024) NULL, -column45 varchar(1024) NULL, -column46 varchar(1024) NULL, -column47 varchar(1024) NULL, -column48 varchar(1024) NULL, -column49 varchar(1024) NULL, -column50 varchar(1024) NULL, -column51 varchar(1024) NULL, -column52 varchar(1024) NULL, -column53 varchar(1024) NULL, -is_rownumber_fetched int4 null, -create_time timestamp DEFAULT current_timestamp -); - - - - diff --git a/MMT_SQL/staging2/DBOECD-TEST-stg2.txt b/MMT_SQL/staging2/DBOECD-TEST-stg2.txt new file mode 100644 index 0000000..1109a46 --- /dev/null +++ b/MMT_SQL/staging2/DBOECD-TEST-stg2.txt @@ -0,0 +1,1435 @@ +--select mmt_staging2.fn_dboecd_test_block(1,1,'DBOECD','DBOECD_TEST',263); + +drop function if exists mmt_staging2.fn_dboecd_test_block; +CREATE OR REPLACE FUNCTION mmt_staging2.fn_dboecd_test_block(p_client_id int,p_function_id int, p_file_format text, +p_sheet_mnemonic text, p_file_syspk int) + RETURNS void AS $$ + declare __make text; + declare __model text; + + declare __client_id int :=p_client_id; + declare __function_id int :=p_function_id; + declare __file_format text :=p_file_format; + declare __sheet_mnemonic text :=p_sheet_mnemonic; + declare __file_syspk int :=p_file_syspk; + + begin + +/************************************************************* +Function Name:fn_dboecd_test_block +Function Desc: This function populates data into staging 2 block +File Format: DBOECD +Sheet Format: DBOECD_TEST +Creation Date: March 25 2021 +Updation Date: +Author: compegence team +Function Call: select mmt_staging2.fn_dboecd_test_block(p_client_id,p_function_id, p_file_format, +p_sheet_mnemonic, p_file_syspk) +***************************************************************/ + +SET search_path TO mmt_staging2; + +/* to process multiple files - re-runnability*/ +truncate table mmt_staging2.dboecd_test_transmission_wheels_int; +truncate table mmt_staging2.dboecd_test_h1_int; +truncate table mmt_staging2.dboecd_test_engine_rpm_engine_to_pto_block; +truncate table mmt_staging2.dboecd_test_engine_rpm_required_pull_block; +truncate table mmt_staging2.dboecd_test_engine_rpm_weight_block; +truncate table mmt_staging2.dboecd_test_engine_rpm_tyre_details_block; +truncate table mmt_staging2.dboecd_test_engine_RPM_tyre_details_int; +truncate table mmt_staging2.dboecd_test_test_condition_block; +truncate table mmt_staging2.dboecd_test_drawbar_performance_selected_summary_block; +truncate table mmt_staging2.dboecd_test_drawbar_performance_gear_performance_block; +truncate table mmt_staging2.dboecd_test_drawbar_performance_fuel_consumption_block; +truncate table mmt_staging2.dboecd_test_test_equipment_used_block; +truncate table mmt_staging2.dboecd_test_measurement_uncertainty_block; +truncate table mmt_staging2.dboecd_test_tractor_specifications_engine_details_block; +truncate table mmt_staging2.dboecd_test_tractor_specifications_cylinders_block; +truncate table mmt_staging2.dboecd_test_tractor_specifications_fuel_and_injection_block; +truncate table mmt_staging2.dboecd_test_tractor_specifications_cleaner_block; +truncate table mmt_staging2.dboecd_test_transmission_clutch_block; +truncate table mmt_staging2.dboecd_test_transmission_drawbar_block; +truncate table mmt_staging2.dboecd_test_transmission_speed_chart_desc_block; +truncate table mmt_staging2.dboecd_test_transmission_wheels_block; +truncate table mmt_staging2.dboecd_test_transmission_fuel_lubricant_int; +truncate table mmt_staging2.dboecd_test_remarks_block; +truncate table mmt_staging2.dboecd_test_remarks_footer_block; +truncate table mmt_staging2.dboecd_test_h1_block; +truncate table mmt_staging2.dboecd_test_transmission_fuel_lubricant_block; +truncate table mmt_staging2.dboecd_test_engine_rpm_rpm_block; +truncate table mmt_staging2.dboecd_test_transmission_speed_chart_block; +truncate table mmt_staging2.stg_specific_table_dboecd_test; +truncate table mmt_staging2.stg_process_table_dboecd_test; +execute 'delete from mmt_ods.fw_jobctrl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a +set row_number_start=null, +row_previous_number=null, +row_read_end=null, +run_time=null +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/*run specific data */ +execute 'insert into mmt_staging2.stg_specific_table_dboecd_test +select * from mmt_staging1.mmt_staging_generic_table a +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' +and a.file_syspk='||p_file_syspk||''; + +/* standardizing keywords */ +update mmt_staging2.stg_specific_table_dboecd_test set column3='Remarks:' where column3 like 'Remarks:%'; +update mmt_staging2.stg_specific_table_dboecd_test set column15='Objective' where column15 like 'Objective%'; + +update mmt_staging2.stg_specific_table_dboecd_test set column3 = TRIM (TRAILING FROM column3 ); +update mmt_staging2.stg_specific_table_dboecd_test set column3 = TRIM (LEADING FROM column3 ); + +/* To process repeated keywords */ +update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified) ; +update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ; +update mmt_ods.mmt_config set F1_source=F1_modified ; +update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source); +update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source); + +/*updating row numbers in mmt_config table*/ + +execute 'update mmt_ods.mmt_config a +set row_number_start=(select min(b.row_number) +from mmt_staging2.stg_specific_table_dboecd_test b +where trim(upper(F1_modified))=trim(upper(column3)) +and b.is_rownumber_fetched is null) +where a.row_number_start is null +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +execute 'update mmt_staging2.stg_specific_table_dboecd_test a +set is_rownumber_fetched=1 +from mmt_ods.mmt_config b +where trim(upper(F1_modified))=trim(upper(column3)) +and b.row_number_start=a.row_number +and is_rownumber_fetched is null +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1 +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a +set row_read_end= (select b.row_number_start +from mmt_ods.mmt_config b +where b.syspk=a.syspk+1 and file_format='''||p_file_format||''' and sheet_mnemonic='''||p_sheet_mnemonic||''' ) +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* update null for the last keyword as read end beacause of overlap of multiple formats*/ +execute 'update mmt_ods.mmt_config a +set row_read_end = null ,run_time=current_timestamp +where f1_modified =''Remarks:'' +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* tagging ranks for each block */ + +execute 'insert into mmt_staging2.stg_process_table_dboecd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_dboecd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Test Request no.'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_dboecd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag from mmt_staging2.stg_specific_table_dboecd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Engine (RPM)'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_dboecd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag from mmt_staging2.stg_specific_table_dboecd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Test condition'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_dboecd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag from mmt_staging2.stg_specific_table_dboecd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Drawbar Performance Test Results (Selected Summary)'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_dboecd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_dboecd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Drawbar Performance Test Results (Gear Performance Test)'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_dboecd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_dboecd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''3.3.2'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_dboecd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_dboecd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Test equipment’s used'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +execute 'insert into mmt_staging2.stg_process_table_dboecd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_dboecd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Tractor specification'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_dboecd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_dboecd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Transmission'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +execute 'insert into mmt_staging2.stg_process_table_dboecd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_dboecd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Remarks:'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/*selecting tactor make*/ +select column6 into __make from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' and trim(' :' from column4)='Make'; + +/*selecting tractor model*/ +select column6 into __model from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_Test_H1' and trim(column3)='Tractor Model'; + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_TEST_H1_BLOCK',__file_format,__sheet_mnemonic,1); +/*selecting first block column and their data*/ +insert into mmt_staging2.DBOECD_TEST_H1_INT (c1,c2,rank) +select a.column3,column6,rank from mmt_staging2.stg_process_table_dboecd_test a where rank_tag='DBOECD_Test_H1' +union +select a.column9,column12,rank from mmt_staging2.stg_process_table_dboecd_test a where rank_tag='DBOECD_Test_H1' +order by column3,"rank"; + +/*execute if using old format*/ +update mmt_staging2.stg_process_table_dboecd_test set column11 = null +where column11 ='-'; +update mmt_staging2.stg_process_table_dboecd_test set column12 = null +where column12 = '-'; +update mmt_staging2.stg_process_table_dboecd_test set column9 = null +where column9 ='-'; +update mmt_staging2.stg_process_table_dboecd_test set column21 = null +where column21 = '-'; +update mmt_staging2.stg_process_table_dboecd_test set column12 = null +where column12 = '…..'; +update mmt_staging2.stg_process_table_dboecd_test set column8 = null +where column8 = '….'; +update mmt_staging2.stg_process_table_dboecd_test set column20 = trim(' Kg' from column20) +where rank =7 and rank_tag = 'DBOECD_test_transmission'; +update mmt_staging2.stg_process_table_dboecd_test set column23 = trim(' Kg' from column23) +where rank =7 and rank_tag = 'DBOECD_test_transmission'; + +/*selecting objective column and its data*/ +insert into mmt_staging2.DBOECD_TEST_H1_INT (c1,c2) +select 'Objective',column15 +from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_Test_H1' +and row_number= +( +select row_number+1 from +mmt_staging2.stg_process_table_dboecd_test a +where column15='Objective' +and rank_tag='DBOECD_Test_H1' +); + +/*selecting acceptance criteria column and its data*/ +insert into mmt_staging2.dboecd_TEST_H1_INT (c1,c2) +select 'Acceptance criteria',column15 +from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_Test_H1' +and row_number= +( +select row_number+1 from +mmt_staging2.stg_process_table_dboecd_test a +where trim(':' from column15)='Acceptance criteria' +and rank_tag='DBOECD_Test_H1' +); + +/*filling h1 block by transposing h1 int block*/ +insert into mmt_staging2.DBOECD_TEST_H1_Block +( +dummy_f, +Customer_Name, +Generation, +No_of_Sample, +Operator_Name, +Project_Group, +Sample_Receipt_Date, +Test_End_Date, +Test_Engineer, +Test_Location, +Test_Report_Date, +Test_Request_no, +Test_Standard_Refer, +Test_Start_Date, +Test_report_No, +Tractor_Model, +Tractor_Sr_No, +Objective, +Acceptance_criteria +) +SELECT * +FROM crosstab( + 'SELECT unnest(''{c2}''::text[]) AS col + , row_number() OVER () + , unnest(ARRAY[c2::text]) AS val + FROM mmt_staging2.DBOECD_TEST_H1_INT + ORDER BY generate_series(1,15),2' + ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text, + a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,a_18 text); + + + /*deleting dummy null record and filling make, model and other id's*/ +delete from mmt_staging2.DBOECD_TEST_H1_Block where dummy_f is null ; + execute 'update mmt_staging2.DBOECD_TEST_H1_Block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_TEST_H1_Block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_TEST_H1_Block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_TEST_H1_Block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_TEST_H1_Block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_TEST_H1_Block set make=__make; + update mmt_staging2.DBOECD_TEST_H1_Block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_TEST_H1_BLOCK'); + +/* engine_RPM_RPM_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_engine_RPM_RPM_block',__file_format,__sheet_mnemonic,2); + +insert into mmt_staging2.DBOECD_test_engine_RPM_RPM_block(dummy_f) values ('dummy'); + +update mmt_staging2.DBOECD_test_engine_RPM_RPM_block +set low_idle_declared=(select column6 from +mmt_staging2.stg_process_table_dboecd_test where rank=2 and column3='Low Idle RPM' and rank_tag='DBOECD_test_engine_RPM') +where dummy_f='dummy'; + +update mmt_staging2.DBOECD_test_engine_RPM_RPM_block +set low_idle_observed=(select column8 from +mmt_staging2.stg_process_table_dboecd_test where rank=2 and column3='Low Idle RPM' and rank_tag='DBOECD_test_engine_RPM') +where dummy_f='dummy'; + +update mmt_staging2.DBOECD_test_engine_RPM_RPM_block +set high_idle_declared=(select column6 from +mmt_staging2.stg_process_table_dboecd_test where rank=3 and column3='High Idle RPM' and rank_tag='DBOECD_test_engine_RPM') +where dummy_f='dummy'; + +update mmt_staging2.DBOECD_test_engine_RPM_RPM_block +set high_idle_observed=(select column8 from +mmt_staging2.stg_process_table_dboecd_test where rank=3 and column3='High Idle RPM' and rank_tag='DBOECD_test_engine_RPM') +where dummy_f='dummy'; + +execute 'update mmt_staging2.DBOECD_test_engine_RPM_RPM_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_RPM_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_RPM_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_RPM_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_RPM_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_engine_RPM_RPM_block set make=__make; + update mmt_staging2.DBOECD_test_engine_RPM_RPM_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_engine_RPM_RPM_block'); + +/*engine_rpm_engine_to_pto_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'dboecd_test_engine_rpm_engine_to_pto_block',__file_format,__sheet_mnemonic,3); + +insert into mmt_staging2.dboecd_test_engine_rpm_engine_to_pto_block(dummy_f) values ('dummy'); + +update mmt_staging2.DBOECD_test_engine_RPM_engine_to_PTO_block set rated_speed= +(select column6 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and rank=4 ) +where dummy_f='dummy'; + +update mmt_staging2.DBOECD_test_engine_RPM_engine_to_PTO_block set engine_to_PTO_ratio= +(select column6 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and rank=5 ) +where dummy_f='dummy'; + +update mmt_staging2.DBOECD_test_engine_RPM_engine_to_PTO_block set wheel_base_mm= +(select column6 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and rank=6 ) +where dummy_f='dummy'; + +update mmt_staging2.DBOECD_test_engine_RPM_engine_to_PTO_block set engine_power_hp= +(select column6 from mmt_staging2.stg_process_table_dboecd_test a +where a.file_format='DBOECD' and a.sheet_mnemonic='DBOECD_TEST' and a.rank_tag='DBOECD_test_engine_RPM' +and rank=7 ) +where dummy_f='dummy'; + +update mmt_staging2.DBOECD_test_engine_RPM_engine_to_PTO_block set PTO_Power_hp= +(select column6 from mmt_staging2.stg_process_table_dboecd_test a +where a.file_format='DBOECD' and a.sheet_mnemonic='DBOECD_TEST' and a.rank_tag='DBOECD_test_engine_RPM' +and rank=8 ) +where dummy_f='dummy'; + +execute 'update mmt_staging2.DBOECD_test_engine_RPM_engine_to_PTO_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_engine_to_PTO_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_engine_to_PTO_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_engine_to_PTO_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_engine_to_PTO_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_engine_RPM_engine_to_PTO_block set make=__make; + update mmt_staging2.DBOECD_test_engine_RPM_engine_to_PTO_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'dboecd_test_engine_rpm_engine_to_pto_block'); + +/*engine_RPM_required_pull_block */ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_engine_RPM_required_pull_block',__file_format,__sheet_mnemonic,4); + + +insert into mmt_staging2.DBOECD_test_engine_RPM_required_pull_block ( pull_type) values ('UB'), ('B'); + +update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block +set required_pull_in_kg=(select column7 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and column3='Required pull in (kg)') +where pull_type='UB'; + +update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block +set required_pull_in_kg=(select column9 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and column3='Required pull in (kg)') +where pull_type='B'; + +update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block +set required_power_in_hp=(select column7 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and column3='Required Power in hp') +where pull_type='UB'; + +update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block +set required_power_in_hp=(select column9 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and column3='Required Power in hp') +where pull_type='B'; + +update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block +set actual_pull_in_kg=(select column7 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and column3='Actual pull in (kg)') +where pull_type='UB'; + +update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block +set actual_pull_in_kg=(select column9 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and column3='Actual pull in (kg)') +where pull_type='B'; + +update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block +set actual_power_in_hp=(select column7 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and column3='actual power in hp') +where pull_type='UB'; + +update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block +set actual_power_in_hp=(select column9 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and column3='actual power in hp') +where pull_type='B'; + +update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block +set calculated_hitch_height_mm=(select column7 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and column3='Calculated hitch height (mm)') +where pull_type='UB'; + +update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block +set calculated_hitch_height_mm=(select column9 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and column3='Calculated hitch height (mm)') +where pull_type='B'; + +update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block +set actual_hitch_height_mm=(select column7 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and column3='Actual hitch height (mm)') +where pull_type='UB'; + +update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block +set actual_hitch_height_mm=(select column9 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and column3='Actual hitch height (mm)') +where pull_type='B'; + +execute 'update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block set make=__make; + update mmt_staging2.DBOECD_test_engine_RPM_required_pull_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_engine_RPM_required_pull_block'); + +/* RPM_weight_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_engine_RPM_weight_block',__file_format,__sheet_mnemonic,5); + +insert into mmt_staging2.DBOECD_test_engine_RPM_weight_block( +weight_kg , +Front , +rear , +Total +) +select column10,column13,column17,column22 from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and rank in(2,3); + +execute 'update mmt_staging2.DBOECD_test_engine_RPM_weight_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_weight_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_weight_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_weight_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_weight_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_engine_RPM_weight_block set make=__make; + update mmt_staging2.DBOECD_test_engine_RPM_weight_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_engine_RPM_weight_block'); + +/*rpm tyre details block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_engine_RPM_tyre_details_block',__file_format,__sheet_mnemonic,6); + + insert into mmt_staging2.DBOECD_test_engine_RPM_tyre_details_int +( s_no,tyre_details,front,rear) + +select column10,column11,column15,column20 +from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_engine_RPM' +and rank >=5 and rank<=14 +order by rank; + + +execute 'update mmt_staging2.DBOECD_test_engine_RPM_tyre_details_int set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_tyre_details_int set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_tyre_details_int set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_tyre_details_int set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_tyre_details_int set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_engine_RPM_tyre_details_int set make=__make; + update mmt_staging2.DBOECD_test_engine_RPM_tyre_details_int set model=__model; + +/*rpm tyre details block*/ + +insert into mmt_staging2.DBOECD_test_engine_RPM_tyre_details_block +( +dummy_f, +tyre_Make, +size, +Ply_Rating, +Load_Carrying_Capacity_in_Kg, +Pressure_kg_cm2, +Number_of_lug, +Number_of_no_load_lug_30m, +Lug_Height, +Dynamic_rolling_radius_mm, +Wheel_Rim_Make_Size +) +SELECT * +FROM crosstab( + 'SELECT unnest(''{front,rear}''::text[]) AS col + , row_number() OVER () + , unnest(ARRAY[front::text,rear::text]) AS val + FROM mmt_staging2.DBOECD_test_engine_RPM_tyre_details_int + ORDER BY generate_series(1,15),2' + ) t ( col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text + ,a_10 text); + + delete from mmt_staging2.DBOECD_test_engine_RPM_tyre_details_block where dummy_f is null; + +execute 'update mmt_staging2.DBOECD_test_engine_RPM_tyre_details_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_tyre_details_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_tyre_details_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_tyre_details_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_engine_RPM_tyre_details_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_engine_RPM_tyre_details_block set make=__make; + update mmt_staging2.DBOECD_test_engine_RPM_tyre_details_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_engine_RPM_tyre_details_block'); + +/* test condition block */ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_test_condition_block',__file_format,__sheet_mnemonic,7); + + +insert into mmt_staging2.DBOECD_test_test_condition_block(c1,c2,c3) +select column3 c1,column10 c2,column15 c3 +from mmt_staging2.stg_process_table_dboecd_test a +where a.rank_tag='DBOECD_test_test_condition'; + + +execute 'update mmt_staging2.DBOECD_test_test_condition_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_test_condition_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_test_condition_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_test_condition_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_test_condition_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_test_condition_block set make=__make; + update mmt_staging2.DBOECD_test_test_condition_block set model=__model; + +update mmt_staging2.dboecd_test_test_condition_block +set c3='B' +where c2='Ballasted'; + + +update mmt_staging2.dboecd_test_test_condition_block +set c3='UB' +where c2='Un-ballasted'; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_test_condition_block'); + +/* performance_selected_summary_block */ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_drawbar_performance_selected_summary_block',__file_format,__sheet_mnemonic,8); + + +insert into mmt_staging2.DBOECD_test_drawbar_performance_selected_summary_block(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25) +select column3 c1, +column4 c2, +column5 c3, +column6 c4, +column7 c5, +column8 c6, +column9 c7, +column10 c8, +column11 c9, +column12 c10, +column13 c11, +column14 c12, +column15 c13, +column16 c14, +column17 c15, +column18 c16, +column19 c17, +column20 c18, +column21 c19, +column22 c20, +column23 c21, +column24 c22, +column25 c23, +column26 c24, +column27 c25 +from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_drawbar_performance_selected_summary' +and rank>3; + + + +execute 'update mmt_staging2.DBOECD_test_drawbar_performance_selected_summary_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_drawbar_performance_selected_summary_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_drawbar_performance_selected_summary_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_drawbar_performance_selected_summary_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_drawbar_performance_selected_summary_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_drawbar_performance_selected_summary_block set make=__make; + update mmt_staging2.DBOECD_test_drawbar_performance_selected_summary_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_drawbar_performance_selected_summary_block'); + + /* Fuel_consumption_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'dboecd_test_drawbar_performance_fuel_consumption_block',__file_format,__sheet_mnemonic,9); + + +insert into mmt_staging2.dboecd_test_drawbar_performance_fuel_consumption_block(c1_1,c2_1,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25) +with fuel_consumtion_data as( +select column3 c1, +column4 c2, +column5 c3, +column6 c4, +column7 c5, +column8 c6, +column9 c7, +column10 c8, +column11 c9, +column12 c10, +column13 c11, +column14 c12, +column15 c13, +column16 c14, +column17 c15, +column18 c16, +column19 c17, +column20 c18, +column21 c19, +column22 c20, +column23 c21, +column24 c22, +column25 c23, +column26 c24, +column27 c25, +rank +from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_fuel_consumption' and column5 is not null +and rank>3), +data_required as +( +select column3 as c1_1,column4 as c2_1 from mmt_staging2.stg_process_table_dboecd_test a where rank_tag='DBOECD_test_fuel_consumption' +and rank>3 and column5 is null +), +stag1_info_table as +(select c1_1,c2_1,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25 +from (select *,row_number() over () as rn from data_required) t1, +(select *,row_number() over () as rn from fuel_consumtion_data)t2 +where t1.rn = t2.rn) +select * from stag1_info_table; + +update mmt_staging2.dboecd_test_drawbar_performance_fuel_consumption_block set Remark = (select replace(column3,'Remark: ','') from mmt_staging2.stg_process_table_dboecd_test where column3 like 'Remark%' and rank_tag='DBOECD_test_fuel_consumption'); + + +execute 'update mmt_staging2.dboecd_test_drawbar_performance_fuel_consumption_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.dboecd_test_drawbar_performance_fuel_consumption_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.dboecd_test_drawbar_performance_fuel_consumption_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.dboecd_test_drawbar_performance_fuel_consumption_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.dboecd_test_drawbar_performance_fuel_consumption_block set file_format='''||p_file_format||''''; + update mmt_staging2.dboecd_test_drawbar_performance_fuel_consumption_block set make=__make; + update mmt_staging2.dboecd_test_drawbar_performance_fuel_consumption_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'dboecd_test_drawbar_performance_fuel_consumption_block'); + + /* performance_gear_summary_block */ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_drawbar_performance_gear_performance_block',__file_format,__sheet_mnemonic,10); + + + insert into mmt_staging2.DBOECD_test_drawbar_performance_gear_performance_block (c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25) +select column3 c1, +column4 c2, +column5 c3, +column6 c4, +column7 c5, +column8 c6, +column9 c7, +column10 c8, +column11 c9, +column12 c10, +column13 c11, +column14 c12, +column15 c13, +column16 c14, +column17 c15, +column18 c16, +column19 c17, +column20 c18, +column21 c19, +column22 c20, +column23 c21, +column24 c22, +column25 c23, +column26 c24, +column27 c25 +from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_drawbar_performance_gear_performance' +and rank>3; + + + +execute 'update mmt_staging2.DBOECD_test_drawbar_performance_gear_performance_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_drawbar_performance_gear_performance_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_drawbar_performance_gear_performance_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_drawbar_performance_gear_performance_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_drawbar_performance_gear_performance_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_drawbar_performance_gear_performance_block set make=__make; + update mmt_staging2.DBOECD_test_drawbar_performance_gear_performance_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_drawbar_performance_gear_performance_block'); + + /*test_equipment_used_block */ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_test_equipment_used_block',__file_format,__sheet_mnemonic,11); + + + insert into mmt_staging2.DBOECD_test_test_equipment_used_block( s_no,instruments,instruments_no,cali_due_date) +select column3,column4,column8,column12 +from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_test_equipment' +and rank>2; + +execute 'update mmt_staging2.DBOECD_test_test_equipment_used_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_test_equipment_used_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_test_equipment_used_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_test_equipment_used_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_test_equipment_used_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_test_equipment_used_block set make=__make; + update mmt_staging2.DBOECD_test_test_equipment_used_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_test_equipment_used_block'); + +/*measurement_uncertainty_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_measurement_uncertainty_block',__file_format,__sheet_mnemonic,12); + + + insert into mmt_staging2.DBOECD_test_measurement_uncertainty_block(dummy_f) values ('dummy'); + +update mmt_staging2.DBOECD_test_measurement_uncertainty_block set load_cell= +(select column20 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_test_equipment' and trim(' :' from column15)='Load cell'); + +update mmt_staging2.DBOECD_test_measurement_uncertainty_block set rpm_meter= +(select column20 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_test_equipment' and trim(' :' from column15)='RPM Meter'); + +update mmt_staging2.DBOECD_test_measurement_uncertainty_block set speed= +(select column20 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_test_equipment' and trim(' :' from column15)='Speed'); + + +update mmt_staging2.DBOECD_test_measurement_uncertainty_block set fuel_flow_meter= +(select column20 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_test_equipment' and trim(' :' from column15)='Fuel Flow meter'); + + + +execute 'update mmt_staging2.DBOECD_test_measurement_uncertainty_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_measurement_uncertainty_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_measurement_uncertainty_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_measurement_uncertainty_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_measurement_uncertainty_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_measurement_uncertainty_block set make=__make; + update mmt_staging2.DBOECD_test_measurement_uncertainty_block set model=__model; + + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_measurement_uncertainty_block'); + + /*tractor_specifications_engine_details_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_tractor_specifications_engine_details_block',__file_format,__sheet_mnemonic,13); + + + insert into mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block(dummy_f) +values ('dummy'); + +update mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block +set make_in_block=(select column6 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :' from column4)='Make' +) +where dummy_f is not null; + + +update mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block +set type=(select column6 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :' from column4)='Type' +) +where dummy_f is not null; + +update mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block +set model_in_block=(select column6 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :' from column4)='Model' +) +where dummy_f is not null; + + +update mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block +set serial_no=(select column6 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :' from column4)='Serial No' +) +where dummy_f is not null; + + +update mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block +set E_P_ratio=(select column6 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :' from column4)='E/P Ratio' +) +where dummy_f is not null; + +update mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block +set rated_speed=(select column6 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :' from column4)='Rated Speed' +) +where dummy_f is not null; + +update mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block +set high_idle=(select column6 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :' from column4)='High Idle' +) +where dummy_f is not null; + +update mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block +set high_idle=(select column6 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :' from column4)='High Idle' +) +where dummy_f is not null; + +update mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block +set low_idle=(select replace(column8,'Low Idle:- ','') from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(column4)='High Idle' +) +where dummy_f is not null; + + +execute 'update mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_engine_details_block set file_format='''||p_file_format||''''; + + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_tractor_specifications_engine_details_block'); + + /*tractor_specifications_cylinders_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_tractor_specifications_cylinders_block',__file_format,__sheet_mnemonic,14); + + + insert into mmt_staging2.DBOECD_test_tractor_specifications_cylinders_block(dummy_f) +values ('dummy'); + +update mmt_staging2.DBOECD_test_tractor_specifications_cylinders_block +set number=(select column11 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :' from column9)='Number' +) +where dummy_f is not null; + +update mmt_staging2.DBOECD_test_tractor_specifications_cylinders_block +set stroke=(select column11 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :' from column9)='Stroke' +) +where dummy_f is not null; + +update mmt_staging2.DBOECD_test_tractor_specifications_cylinders_block +set bore=(select column11 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :' from column9)='Bore' +) +where dummy_f is not null; + +update mmt_staging2.DBOECD_test_tractor_specifications_cylinders_block +set capacity=(select column11 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :' from column9)='Capacity' +) +where dummy_f is not null; + + +execute 'update mmt_staging2.DBOECD_test_tractor_specifications_cylinders_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_cylinders_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_cylinders_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_cylinders_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_cylinders_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_tractor_specifications_cylinders_block set make=__make; + update mmt_staging2.DBOECD_test_tractor_specifications_cylinders_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_tractor_specifications_cylinders_block'); + + /*fuel_and_injection_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_tractor_specifications_fuel_and_injection_block',__file_format,__sheet_mnemonic,15); + + + insert into mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block(dummy_f) +values ('dummy'); + +update mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block +set Make_type_and_model_of_injection_pump=(select column17 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(column12)='Make, type and model of injection pump' +) +where dummy_f is not null; + +update mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block +set capacity_of_fuel_tank_lit=(select column17 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim('. :-' from column12)='Capacity of fuel tank, lit' +) +where dummy_f is not null; + +update mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block +set Make_type_and_model_of_injection_pump=(select column17 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :-' from column12)='Make, type and model of injection pump' +) +where dummy_f is not null; + +update mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block +set Manufacturer_production_setting=(select column17 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :-' from column12)='Manufacturer’s production setting' +) +where dummy_f is not null; + +update mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block +set Make_type_and_model_of_injectors=(select column17 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :-' from column12)='Make, type and model of injectors' +) +where dummy_f is not null; + +update mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block +set Make_type_and_model_of_magneto_coil_and_distributor=(select column17 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :-' from column12)='Make, type and model of magneto, coil and distributor' +) +where dummy_f is not null; + +update mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block +set Make_type_and_model_of_carburetor=(select column17 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :-' from column12)='Make, type and model of carburetor' +) +where dummy_f is not null; + +update mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block +set Ignition_or_injection_timing_Manual_or_automatic=(select column17 from mmt_staging2.stg_process_table_dboecd_test a +where rank_tag='DBOECD_test_tractor_specifications' +and trim(' :-' from column12)='Ignition or injection timing (Manual or automatic)' +) +where dummy_f is not null; + + +execute 'update mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block set make=__make; + update mmt_staging2.DBOECD_test_tractor_specifications_fuel_and_injection_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_tractor_specifications_fuel_and_injection_block'); + + /*tractor_specifications_cleaner_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_tractor_specifications_cleaner_block',__file_format,__sheet_mnemonic,16); + + + insert into mmt_staging2.DBOECD_test_tractor_specifications_cleaner_block(cleaner_type) +values ('Air cleaner'),('Precleaner (if fitted)'); + +update mmt_staging2.DBOECD_test_tractor_specifications_cleaner_block +set make_and_model = +(select column23 from mmt_staging2.stg_process_table_dboecd_test a where + rank_tag='DBOECD_test_tractor_specifications' +and column21='Make and model' and rank=3) +where cleaner_type='Air cleaner'; + +update mmt_staging2.DBOECD_test_tractor_specifications_cleaner_block +set type= +(select column23 from mmt_staging2.stg_process_table_dboecd_test a where + rank_tag='DBOECD_test_tractor_specifications' +and column21='Type' and rank=5) +where cleaner_type='Air cleaner'; + +update mmt_staging2.DBOECD_test_tractor_specifications_cleaner_block +set make_and_model = +(select column23 from mmt_staging2.stg_process_table_dboecd_test a where + rank_tag='DBOECD_test_tractor_specifications' +and column21='Make and model' and rank=7) +where cleaner_type='Precleaner (if fitted)'; + +update mmt_staging2.DBOECD_test_tractor_specifications_cleaner_block +set type= +(select column23 from mmt_staging2.stg_process_table_dboecd_test a where +rank_tag='DBOECD_test_tractor_specifications' +and column21='Type' and rank=9) +where cleaner_type='Precleaner (if fitted)'; + + +execute 'update mmt_staging2.DBOECD_test_tractor_specifications_cleaner_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_cleaner_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_cleaner_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_cleaner_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_tractor_specifications_cleaner_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_tractor_specifications_cleaner_block set make=__make; + update mmt_staging2.DBOECD_test_tractor_specifications_cleaner_block set model=__model; + + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_tractor_specifications_cleaner_block'); + + /*transmission_clutch_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_transmission_clutch_block',__file_format,__sheet_mnemonic,17); + + + insert into mmt_staging2.DBOECD_test_transmission_clutch_block(dummy_f) values ('dummy'); + + +update mmt_staging2.DBOECD_test_transmission_clutch_block a +set clutch_type=( +select column6 from mmt_staging2.stg_process_table_dboecd_test b +where trim(' :' from b.column3)='Type' and rank=2 and b.rank_tag='DBOECD_test_transmission') +where dummy_F='dummy'; + +update mmt_staging2.DBOECD_test_transmission_clutch_block a +set steering_type=( +select column6 from mmt_staging2.stg_process_table_dboecd_test b +where trim(' :' from b.column3)='Type' and rank=5 and b.rank_tag='DBOECD_test_transmission') +where dummy_F='dummy'; + +update mmt_staging2.DBOECD_test_transmission_clutch_block a +set diameter_of_disc_mm=( +select column6 from mmt_staging2.stg_process_table_dboecd_test b +where trim(' :' from b.column3)='Diameter of disc, mm' and b.rank_tag='DBOECD_test_transmission') +where dummy_F='dummy'; + + +execute 'update mmt_staging2.DBOECD_test_transmission_clutch_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_transmission_clutch_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_transmission_clutch_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_transmission_clutch_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_transmission_clutch_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_transmission_clutch_block set make=__make; + update mmt_staging2.DBOECD_test_transmission_clutch_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_transmission_clutch_block'); + + /*transmission_drawbar_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_transmission_drawbar_block',__file_format,__sheet_mnemonic,18); + +insert into mmt_staging2.DBOECD_test_transmission_drawbar_block(dummy_f) values ('dummy'); + +update mmt_staging2.DBOECD_test_transmission_drawbar_block a +set type=( +select column8 from mmt_staging2.stg_process_table_dboecd_test b +where trim(' :' from b.column3)='Type' and rank=7 and b.rank_tag='DBOECD_test_transmission') +where dummy_F='dummy'; + +update mmt_staging2.DBOECD_test_transmission_drawbar_block a +set Height_above_ground_max_mm=( +select column8 from mmt_staging2.stg_process_table_dboecd_test b +where trim(' :' from b.column3)='Height above ground (max), mm' and rank=9 and b.rank_tag='DBOECD_test_transmission') +where dummy_F='dummy'; + +update mmt_staging2.DBOECD_test_transmission_drawbar_block a +set Height_above_ground_min_mm=( +select column8 from mmt_staging2.stg_process_table_dboecd_test b +where trim(' :' from b.column3)='Height above ground (min), mm' and rank=11 and b.rank_tag='DBOECD_test_transmission') +where dummy_F='dummy'; + +update mmt_staging2.DBOECD_test_transmission_drawbar_block a +set Position_related_to_PTO=( +select column8 from mmt_staging2.stg_process_table_dboecd_test b +where trim(' :' from b.column3)='Position related to PTO' and rank=13 and b.rank_tag='DBOECD_test_transmission') +where dummy_F='dummy'; + +update mmt_staging2.DBOECD_test_transmission_drawbar_block a +set Wheel_Base=( +select column8 from mmt_staging2.stg_process_table_dboecd_test b +where trim(' :' from b.column3)='Wheel Base' and rank=15 and b.rank_tag='DBOECD_test_transmission') +where dummy_F='dummy'; + + execute 'update mmt_staging2.DBOECD_test_transmission_drawbar_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_transmission_drawbar_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_transmission_drawbar_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_transmission_drawbar_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_transmission_drawbar_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_transmission_drawbar_block set make=__make; + update mmt_staging2.DBOECD_test_transmission_drawbar_block set model=__model; + + update mmt_staging2.dboecd_test_transmission_drawbar_block a +set test_condition=b.c3 +from mmt_staging2.dboecd_test_test_condition_block b +where a.file_syspk=b.file_syspk; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_transmission_drawbar_block'); + +/*transmission_speed_chart_desc_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_transmission_speed_chart_desc_block',__file_format,__sheet_mnemonic,19); + +insert into mmt_staging2.DBOECD_test_transmission_speed_chart_desc_block +(descr) +select column10 +from +mmt_staging2.stg_process_table_dboecd_test b +where b.rank_tag='DBOECD_test_transmission' +and rank=1; + + +execute 'update mmt_staging2.DBOECD_test_transmission_speed_chart_desc_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_transmission_speed_chart_desc_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_transmission_speed_chart_desc_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_transmission_speed_chart_desc_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_transmission_speed_chart_desc_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_transmission_speed_chart_desc_block set make=__make; + update mmt_staging2.DBOECD_test_transmission_speed_chart_desc_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_transmission_speed_chart_desc_block'); + +/*transmission_speed_chart_desc_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_transmission_speed_chart_block',__file_format,__sheet_mnemonic,20); + /*transmission_speed_chart_block*/ + insert into mmt_staging2.DBOECD_test_transmission_speed_chart_block +(gear,forward,reverse) +select column10,column11, column13 from +mmt_staging2.stg_process_table_dboecd_test b +where b.rank_tag='DBOECD_test_transmission' +and rank>=3; + + +execute 'update mmt_staging2.dboecd_test_transmission_speed_chart_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.dboecd_test_transmission_speed_chart_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.dboecd_test_transmission_speed_chart_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.dboecd_test_transmission_speed_chart_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.dboecd_test_transmission_speed_chart_block set file_format='''||p_file_format||''''; + update mmt_staging2.dboecd_test_transmission_speed_chart_block set make=__make; + update mmt_staging2.dboecd_test_transmission_speed_chart_block set model=__model; + delete from mmt_staging2.dboecd_test_transmission_speed_chart_block where gear is null; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_transmission_speed_chart_block'); + +/*transmission_wheels_in*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_transmission_wheels_block',__file_format,__sheet_mnemonic,21); + +insert into mmt_staging2.DBOECD_test_transmission_wheels_int(Descriptions,Steered_wheels,Driving_wheel) +select column15,column20,column23 from mmt_staging2.stg_process_table_dboecd_test b +where b.rank_tag='DBOECD_test_transmission' +and rank>=3 and rank<=11 +order by rank; + +update mmt_staging2.DBOECD_test_transmission_wheels_int +set Driving_wheel=Steered_wheels +where trim(' :' from Descriptions)='Location of driving wheel' +and Driving_wheel =''; + + +execute 'update mmt_staging2.DBOECD_test_transmission_wheels_int set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_transmission_wheels_int set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_transmission_wheels_int set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_transmission_wheels_int set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_transmission_wheels_int set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_transmission_wheels_int set make=__make; + update mmt_staging2.DBOECD_test_transmission_wheels_int set model=__model; + + + /*transmission_wheels_block*/ +insert into mmt_staging2.dboecd_test_transmission_wheels_block + ( + dummy_f, + Location_of_driving_wheel, +Make_of_tyres, +types, +size, +Maximum_permissible_load_kg, +Ply_rating, +Track_width_max_mm, +Track_width_min_mm, +Inflation_pressure_kg_cm2 + + ) + SELECT * +FROM crosstab( + 'SELECT unnest(''{steered_wheels,driving_wheel}''::text[]) AS col + , row_number() OVER () + , unnest(ARRAY[steered_wheels::text,driving_wheel::text]) AS val + FROM mmt_staging2.dboecd_test_transmission_wheels_int + ORDER BY generate_series(1,10),2' + ) t ( col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text); + +delete from dboecd_test_transmission_wheels_block where dummy_f is null; + + +execute 'update mmt_staging2.dboecd_test_transmission_wheels_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.dboecd_test_transmission_wheels_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.dboecd_test_transmission_wheels_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.dboecd_test_transmission_wheels_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.dboecd_test_transmission_wheels_block set file_format='''||p_file_format||''''; + update mmt_staging2.dboecd_test_transmission_wheels_block set make=__make; + update mmt_staging2.dboecd_test_transmission_wheels_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_transmission_wheels_block'); + +/*transmission_fuel_lubricant*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_transmission_fuel_lubricant_block',__file_format,__sheet_mnemonic,22); + + +insert into mmt_staging2.DBOECD_test_transmission_fuel_lubricant_int( Descriptions,Diesel_BS_IV,Engine_oil,Transmission_oil) +select column15,column18,column20,column23 from mmt_staging2.stg_process_table_dboecd_test b +where b.rank_tag='DBOECD_test_transmission' +and rank>=14 and rank<=18 +order by rank; + + +execute 'update mmt_staging2.DBOECD_test_transmission_fuel_lubricant_int set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_transmission_fuel_lubricant_int set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_transmission_fuel_lubricant_int set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_transmission_fuel_lubricant_int set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_transmission_fuel_lubricant_int set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_transmission_fuel_lubricant_int set make=__make; + update mmt_staging2.DBOECD_test_transmission_fuel_lubricant_int set model=__model; + + +/*transmission_fuel_lubricant_block*/ +insert into mmt_staging2.DBOECD_test_transmission_fuel_lubricant_block + ( + dummy_f, + Trade_name, +type, +Octane_Cetane_number, +Viscosity, +Density_at_15C +) +SELECT * +FROM crosstab( + 'SELECT unnest(''{diesel_bs_iv,engine_oil,transmission_oil}''::text[]) AS col + , row_number() OVER () + , unnest(ARRAY[diesel_bs_iv::text,engine_oil::text,transmission_oil::text]) AS val + FROM mmt_staging2.DBOECD_test_transmission_fuel_lubricant_int + ORDER BY generate_series(1,15),2' + ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text); + + delete from DBOECD_test_transmission_fuel_lubricant_block where dummy_f is null; + +execute 'update mmt_staging2.DBOECD_test_transmission_fuel_lubricant_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_transmission_fuel_lubricant_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_transmission_fuel_lubricant_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_transmission_fuel_lubricant_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_transmission_fuel_lubricant_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_transmission_fuel_lubricant_block set make=__make; + update mmt_staging2.DBOECD_test_transmission_fuel_lubricant_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_transmission_fuel_lubricant_block'); + +/*DBOECD_test_remarks_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_remarks_block',__file_format,__sheet_mnemonic,23); + +insert into mmt_staging2.DBOECD_test_remarks_block +( +remarks , +parameter , +acceptance_criteria, +observations +) +select column3,column13,column15,column23 from mmt_staging2.stg_process_table_dboecd_test b +where b.rank_tag='DBOECD_test_remarks' +and rank>3 and rank<=5; + + +execute 'update mmt_staging2.DBOECD_test_remarks_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_remarks_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_remarks_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_remarks_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_remarks_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_remarks_block set make=__make; + update mmt_staging2.DBOECD_test_remarks_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_remarks_block'); + +/*DBOECD_test_remarks_footer_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBOECD_test_remarks_footer_block',__file_format,__sheet_mnemonic,24); + +insert into mmt_staging2.DBOECD_test_remarks_footer_block(dummy_f) values ('dummy'); + +update mmt_staging2.DBOECD_test_remarks_footer_block a +set prepared_by=( select column7 from mmt_staging2.stg_process_table_dboecd_test b +where b.rank_tag='DBOECD_test_remarks' +and trim(column3)='Prepared by' ) +where dummy_F='dummy'; + +--update mmt_staging2.DBOECD_test_remarks_footer_block a +--set reviewed_by=( select column7 from mmt_staging2.stg_process_table_dboecd_test b +--where b.rank_tag='DBOECD_test_remarks' +--and trim(column3)='Reviewed by' ) +--where dummy_F='dummy'; + +update mmt_staging2.DBOECD_test_remarks_footer_block a +set approved_by=( select column7 from mmt_staging2.stg_process_table_dboecd_test b +where b.rank_tag='DBOECD_test_remarks' +and trim(column3)='Approved by' ) +where dummy_F='dummy'; + +update mmt_staging2.DBOECD_test_remarks_footer_block a +set comments=( select column3 from mmt_staging2.stg_process_table_dboecd_test b +where b.rank_tag='DBOECD_test_remarks' +and rank=9 ) +where dummy_F='dummy'; + +update mmt_staging2.DBOECD_test_remarks_footer_block a +set rev1=( select column3 from mmt_staging2.stg_process_table_dboecd_test b +where b.rank_tag='DBOECD_test_remarks' +and rank=10 ) +where dummy_F='dummy'; + + +update mmt_staging2.DBOECD_test_remarks_footer_block a +set rev2=( select column9 from mmt_staging2.stg_process_table_dboecd_test b +where b.rank_tag='DBOECD_test_remarks' +and rank=10 ) +where dummy_F='dummy'; + +update mmt_staging2.DBOECD_test_remarks_footer_block a +set rev3=( select column18 from mmt_staging2.stg_process_table_dboecd_test b +where b.rank_tag='DBOECD_test_remarks' +and rank=10 ) +where dummy_F='dummy'; + +update mmt_staging2.DBOECD_test_remarks_footer_block a +set replaces=( select column23 from mmt_staging2.stg_process_table_dboecd_test b +where b.rank_tag='DBOECD_test_remarks' +and rank=6) +where dummy_F='dummy'; + +update mmt_staging2.DBOECD_test_remarks_footer_block a +set revision_no=( select column23 from mmt_staging2.stg_process_table_dboecd_test b +where b.rank_tag='DBOECD_test_remarks' +and rank=7) +where dummy_F='dummy'; + +update mmt_staging2.DBOECD_test_remarks_footer_block a +set date=( select column19 from mmt_staging2.stg_process_table_dboecd_test b +where b.rank_tag='DBOECD_test_remarks' +and rank=6) +where dummy_F='dummy'; + +update mmt_staging2.DBOECD_test_remarks_footer_block a +set date=( select column19 from mmt_staging2.stg_process_table_dboecd_test b +where b.rank_tag='DBOECD_test_remarks' +and rank=7 and column9 is not null) +where dummy_F='dummy'; + + +execute 'update mmt_staging2.DBOECD_test_remarks_footer_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBOECD_test_remarks_footer_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBOECD_test_remarks_footer_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.DBOECD_test_remarks_footer_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.DBOECD_test_remarks_footer_block set file_format='''||p_file_format||''''; + update mmt_staging2.DBOECD_test_remarks_footer_block set make=__make; + update mmt_staging2.DBOECD_test_remarks_footer_block set model=__model; +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBOECD_test_remarks_footer_block'); + +end +$$ LANGUAGE plpgsql; + diff --git a/MMT_SQL/staging2/DBSTD_TEST_stg2.SQL b/MMT_SQL/staging2/DBSTD_TEST_stg2.SQL new file mode 100644 index 0000000..8970744 --- /dev/null +++ b/MMT_SQL/staging2/DBSTD_TEST_stg2.SQL @@ -0,0 +1,1332 @@ +drop function if exists mmt_staging2.fn_dbstd_test_block; +CREATE OR REPLACE FUNCTION mmt_staging2.fn_dbstd_test_block(p_client_id int,p_function_id int, p_file_format text, +p_sheet_mnemonic text, p_file_syspk int) + RETURNS void AS $$ + declare __make text; + declare __model text; + + declare __client_id int :=p_client_id; + declare __function_id int :=p_function_id; + declare __file_format text :=p_file_format; + declare __sheet_mnemonic text :=p_sheet_mnemonic; + declare __file_syspk int :=p_file_syspk; + + begin + +/************************************************************ +Function Name:fn_dbstd_test_block +Function Desc: This function populates data into staging 2 block +File Format: DBSTD +Sheet Format: DBSTD_TEST +Creation Date: March 25 2021 +Updation Date: +Author: compegence team +Function Call: select mmt_staging2.fn_dbstd_test_block(p_client_id,p_function_id, p_file_format, +p_sheet_mnemonic, p_file_syspk) +Function call ex: select mmt_staging2.fn_dbstd_test_block(1,2,'DBSTD','DBSTD_TEST',262) +***************************************************************/ + + +SET search_path TO mmt_staging2; + +/* to process multiple files - re-runnability*/ + +truncate table mmt_staging2.dbstd_test_transmission_wheels_int; +truncate table mmt_staging2.dbstd_test_h1_int; +truncate table mmt_staging2.dbstd_test_engine_rpm_engine_to_pto_block; +truncate table mmt_staging2.dbstd_test_engine_rpm_required_pull_block; +truncate table mmt_staging2.dbstd_test_engine_rpm_weight_block; +truncate table mmt_staging2.dbstd_test_engine_rpm_tyre_details_block; +truncate table mmt_staging2.DBSTD_test_engine_RPM_tyre_details_int; +truncate table mmt_staging2.dbstd_test_test_condition_block; +truncate table mmt_staging2.dbstd_test_drawbar_performance_selected_summary_block; +truncate table mmt_staging2.dbstd_test_drawbar_performance_gear_performance_block; +truncate table mmt_staging2.dbstd_test_test_equipment_used_block; +truncate table mmt_staging2.dbstd_test_measurement_uncertainty_block; +truncate table mmt_staging2.dbstd_test_tractor_specifications_engine_details_block; +truncate table mmt_staging2.dbstd_test_tractor_specifications_cylinders_block; +truncate table mmt_staging2.dbstd_test_tractor_specifications_fuel_and_injection_block; +truncate table mmt_staging2.dbstd_test_tractor_specifications_cleaner_block; +truncate table mmt_staging2.dbstd_test_transmission_clutch_block; +truncate table mmt_staging2.dbstd_test_transmission_drawbar_block; +truncate table mmt_staging2.dbstd_test_transmission_speed_chart_desc_block; +truncate table mmt_staging2.dbstd_test_transmission_wheels_block; +truncate table mmt_staging2.dbstd_test_transmission_fuel_lubricant_int; +truncate table mmt_staging2.dbstd_test_remarks_block; +truncate table mmt_staging2.dbstd_test_remarks_footer_block; +truncate table mmt_staging2.dbstd_test_h1_block; +truncate table mmt_staging2.dbstd_test_transmission_fuel_lubricant_block; +truncate table mmt_staging2.dbstd_test_engine_rpm_rpm_block; +truncate table mmt_staging2.dbstd_test_transmission_speed_chart_block; +truncate table mmt_staging2.stg_specific_table_dbstd_test; +truncate table mmt_staging2.stg_process_table_dbstd_test; + + +execute 'delete from mmt_ods.fw_jobctrl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +execute 'update mmt_ods.mmt_config a +set row_number_start=null, +row_previous_number=null, +row_read_end=null, +run_time=null +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/*run specific data */ +execute 'insert into mmt_staging2.stg_specific_table_dbstd_test +select * from mmt_staging1.mmt_staging_generic_table a +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' +and a.file_syspk='||p_file_syspk||''; + + +/* standardizing keywords */ +update mmt_staging2.stg_specific_table_dbstd_test set column3='Remarks' where column3 like 'Remarks%'; +update mmt_staging2.stg_specific_table_dbstd_test set column15='Objective' where column15 like 'Objective%'; + +update mmt_staging2.stg_specific_table_dbstd_test set column3 = TRIM (TRAILING FROM column3 ); +update mmt_staging2.stg_specific_table_dbstd_test set column3 = TRIM (LEADING FROM column3 ); + +/* To process repeated keywords */ +update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified) ; +update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ; +update mmt_ods.mmt_config set F1_source=F1_modified ; +update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source); +update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source); + +/*updating row numbers in mmt_config table*/ +execute 'update mmt_ods.mmt_config a +set row_number_start=(select min(b.row_number) +from mmt_staging2.stg_specific_table_dbstd_test b +where trim(upper(F1_modified))=trim(upper(column3)) +and b.is_rownumber_fetched is null) +where a.row_number_start is null +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +execute 'update mmt_staging2.stg_specific_table_dbstd_test a +set is_rownumber_fetched=1 +from mmt_ods.mmt_config b +where trim(upper(F1_modified))=trim(upper(column3)) +and b.row_number_start=a.row_number +and is_rownumber_fetched is null +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1 +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a +set row_read_end= (select b.row_number_start +from mmt_ods.mmt_config b +where b.syspk=a.syspk+1 and file_format='''||p_file_format||''' and sheet_mnemonic='''||p_sheet_mnemonic||''' ) +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* update null for the last keyword as read end beacause of overlap of multiple formats*/ +execute 'update mmt_ods.mmt_config a +set row_read_end = null ,run_time=current_timestamp +where f1_modified =''Remarks'' +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* tagging ranks*/ + +execute 'insert into mmt_staging2.stg_process_table_dbstd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_dbstd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Test Request no.'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_dbstd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag from mmt_staging2.stg_specific_table_dbstd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Engine (RPM)'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_dbstd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag from mmt_staging2.stg_specific_table_dbstd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Test condition'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_dbstd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag from mmt_staging2.stg_specific_table_dbstd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Drawbar Performance Test Results (Selected Summary)'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_dbstd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_dbstd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Drawbar Performance Test Results (Gear Performance Test)'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +execute 'insert into mmt_staging2.stg_process_table_dbstd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_dbstd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Test equipment’s used'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +execute 'insert into mmt_staging2.stg_process_table_dbstd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_dbstd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Tractor specification'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_dbstd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_dbstd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Transmission'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +execute 'insert into mmt_staging2.stg_process_table_dbstd_test +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_dbstd_test a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Remarks'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +/*selecting tactor make*/ +select column6 into __make from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' and trim(column4)='Make' ; + +select column6 into __model from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' and trim(column4)='Model'; + + +/*block starts - DBSTD_TEST_H1_BLOCK */ + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_TEST_H1_BLOCK',__file_format,__sheet_mnemonic,1); + +insert into mmt_staging2.DBSTD_TEST_H1_INT (c1,c2) +select a.column3,column6 from mmt_staging2.stg_process_table_dbstd_test a where rank_tag='DBSTD_Test_H1'; + +insert into mmt_staging2.DBSTD_TEST_H1_INT (c1,c2) +select a.column9,column12 from mmt_staging2.stg_process_table_dbstd_test a where rank_tag='DBSTD_Test_H1'; + +insert into mmt_staging2.DBSTD_TEST_H1_INT (c1,c2) +select 'Objective',column15 +from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_Test_H1' +and row_number= +( +select row_number+1 from +mmt_staging2.stg_process_table_dbstd_test a +where column15='Objective' +and rank_tag='DBSTD_Test_H1' +); + +insert into mmt_staging2.DBSTD_TEST_H1_INT (c1,c2) +select 'Acceptance criteria',column15 +from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_Test_H1' +and row_number= +( +select row_number+1 from +mmt_staging2.stg_process_table_dbstd_test a +where column15='Acceptance criteria' +and rank_tag='DBSTD_Test_H1' +); + +insert into mmt_staging2.DBSTD_TEST_H1_Block +( +dummy_f, +Test_Request_no, +Sample_Receipt_Date, +Test_report_No, +Tractor_Model, +Generation, +Customer_Name, +Test_Engineer, +Test_Report_Date, +No_of_Sample, +Test_Start_Date, +Test_End_Date, +Tractor_Sr_No, +Test_Standard_Refer, +Test_Location, +Operator_Name, +Project_Group, +Objective, +Acceptance_criteria +) +SELECT * +FROM crosstab( + 'SELECT unnest(''{c2}''::text[]) AS col + , row_number() OVER () + , unnest(ARRAY[c2::text]) AS val + FROM mmt_staging2.DBSTD_TEST_H1_INT + ORDER BY generate_series(1,15),2' + ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text, + a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,a_18 text); + + + delete from mmt_staging2.DBSTD_TEST_H1_Block where dummy_f is null ; + execute 'update mmt_staging2.DBSTD_TEST_H1_Block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_TEST_H1_Block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_TEST_H1_Block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_TEST_H1_Block set make=__make; + update mmt_staging2.DBSTD_TEST_H1_Block set model=__model; + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_TEST_H1_BLOCK'); + + /* block DBSTD_test_engine_RPM_RPM_block */ + perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_engine_RPM_RPM_block',__file_format,__sheet_mnemonic,2); + +insert into mmt_staging2.DBSTD_test_engine_RPM_RPM_block(dummy_f) values ('dummy'); + +update mmt_staging2.DBSTD_test_engine_RPM_RPM_block +set low_idle_declared=(select column6 from +mmt_staging2.stg_process_table_dbstd_test where rank=2 and column3='Low Idle RPM' and rank_tag='DBSTD_test_engine_RPM') +where dummy_f='dummy'; + +update mmt_staging2.DBSTD_test_engine_RPM_RPM_block +set low_idle_observed=(select column8 from +mmt_staging2.stg_process_table_dbstd_test where rank=2 and column3='Low Idle RPM' and rank_tag='DBSTD_test_engine_RPM') +where dummy_f='dummy'; + +update mmt_staging2.DBSTD_test_engine_RPM_RPM_block +set high_idle_declared=(select column6 from +mmt_staging2.stg_process_table_dbstd_test where rank=3 and column3='High Idle RPM' and rank_tag='DBSTD_test_engine_RPM') +where dummy_f='dummy'; + +update mmt_staging2.DBSTD_test_engine_RPM_RPM_block +set high_idle_observed=(select column8 from +mmt_staging2.stg_process_table_dbstd_test where rank=3 and column3='High Idle RPM' and rank_tag='DBSTD_test_engine_RPM') +where dummy_f='dummy'; + + +execute 'update mmt_staging2.DBSTD_test_engine_RPM_RPM_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_engine_RPM_RPM_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_engine_RPM_RPM_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_engine_RPM_RPM_block set make=__make; + update mmt_staging2.DBSTD_test_engine_RPM_RPM_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_engine_RPM_RPM_block'); + + /* block DBSTD_test_engine_RPM_engine_to_PTO_block*/ + + perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'dbstd_test_engine_rpm_engine_to_pto_block',__file_format,__sheet_mnemonic,3); +insert into mmt_staging2.DBSTD_test_engine_RPM_engine_to_PTO_block(dummy_f) values ('dummy'); + + +update mmt_staging2.DBSTD_test_engine_RPM_engine_to_PTO_block set rated_speed= +(select column6 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and rank=4 ) +where dummy_f='dummy'; + +update mmt_staging2.DBSTD_test_engine_RPM_engine_to_PTO_block set engine_to_PTO_ratio= +(select column6 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and rank=5 ) +where dummy_f='dummy'; + +update mmt_staging2.DBSTD_test_engine_RPM_engine_to_PTO_block set wheel_base_mm= +(select column6 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and rank=6 ) +where dummy_f='dummy'; + + +update mmt_staging2.DBSTD_test_engine_RPM_engine_to_PTO_block set engine_power_hp= +(select column6 from mmt_staging2.stg_process_table_dbstd_test a +where a.file_format='DBSTD' and a.sheet_mnemonic='DBSTD_TEST' and a.rank_tag='DBSTD_test_engine_RPM' +and rank=7 ) +where dummy_f='dummy'; + +update mmt_staging2.DBSTD_test_engine_RPM_engine_to_PTO_block set PTO_Power_hp= +(select column6 from mmt_staging2.stg_process_table_dbstd_test a +where a.file_format='DBSTD' and a.sheet_mnemonic='DBSTD_TEST' and a.rank_tag='DBSTD_test_engine_RPM' +and rank=8 ) +where dummy_f='dummy'; + + +execute 'update mmt_staging2.DBSTD_test_engine_RPM_engine_to_PTO_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_engine_RPM_engine_to_PTO_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_engine_RPM_engine_to_PTO_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_engine_RPM_engine_to_PTO_block set make=__make; + update mmt_staging2.DBSTD_test_engine_RPM_engine_to_PTO_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'dbstd_test_engine_rpm_engine_to_pto_block'); + +/* block DBSTD_test_engine_RPM_required_pull_block */ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_engine_RPM_required_pull_block',__file_format,__sheet_mnemonic,4); + +insert into mmt_staging2.DBSTD_test_engine_RPM_required_pull_block ( pull_type) values ('UB'), ('B'); + +update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block +set required_pull_in_kg=(select column7 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and column3='Required pull in (kg)') +where pull_type='UB'; + +update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block +set required_pull_in_kg=(select column9 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and column3='Required pull in (kg)') +where pull_type='B'; + +update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block +set required_power_in_hp=(select column7 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and column3='Required Power in hp') +where pull_type='UB'; + +update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block +set required_power_in_hp=(select column9 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and column3='Required Power in hp') +where pull_type='B'; + +update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block +set actual_pull_in_kg=(select column7 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and column3='Actual pull in (kg)') +where pull_type='UB'; + +update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block +set actual_pull_in_kg=(select column9 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and column3='Actual pull in (kg)') +where pull_type='B'; + +update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block +set actual_power_in_hp=(select column7 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and column3='actual power in hp') +where pull_type='UB'; + +update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block +set actual_power_in_hp=(select column9 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and column3='actual power in hp') +where pull_type='B'; + +update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block +set calculated_hitch_height_mm=(select column7 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and column3='Calculated hitch height (mm)') +where pull_type='UB'; + +update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block +set calculated_hitch_height_mm=(select column9 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and column3='Calculated hitch height (mm)') +where pull_type='B'; + +update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block +set actual_hitch_height_mm=(select column7 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and column3='Actual hitch height (mm)') +where pull_type='UB'; + +update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block +set actual_hitch_height_mm=(select column9 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and column3='Actual hitch height (mm)') +where pull_type='B'; + + +execute 'update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block set make=__make; + update mmt_staging2.DBSTD_test_engine_RPM_required_pull_block set model=__model; + + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_engine_RPM_required_pull_block'); + + /* block DBSTD_test_engine_RPM_weight_block */ + perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_engine_RPM_weight_block',__file_format,__sheet_mnemonic,5); + +insert into mmt_staging2.DBSTD_test_engine_RPM_weight_block( +weight_kg , +Front , +rear , +Total +) +select column10,column13,column17,column22 from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and rank in(2,3); + + +execute 'update mmt_staging2.DBSTD_test_engine_RPM_weight_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_engine_RPM_weight_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_engine_RPM_weight_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_engine_RPM_weight_block set make=__make; + update mmt_staging2.DBSTD_test_engine_RPM_weight_block set model=__model; +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_engine_RPM_weight_block'); + +/*block - rpm tyre details block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_engine_RPM_tyre_details_block',__file_format,__sheet_mnemonic,6); + +insert into mmt_staging2.DBSTD_test_engine_RPM_tyre_details_int +( s_no,tyre_details,front,rear) + +select column10,column11,column15,column20 +from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_engine_RPM' +and rank >=5 and rank<=14; + + +execute 'update mmt_staging2.DBSTD_test_engine_RPM_tyre_details_int set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_engine_RPM_tyre_details_int set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_engine_RPM_tyre_details_int set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_engine_RPM_tyre_details_int set make=__make; + update mmt_staging2.DBSTD_test_engine_RPM_tyre_details_int set model=__model; + +insert into mmt_staging2.DBSTD_test_engine_RPM_tyre_details_block +( +dummy_f, +tyre_Make, +size, +Ply_Rating, +Load_Carrying_Capacity_in_Kg, +Pressure_kg_cm2, +Number_of_lug, +Number_of_no_load_lug_30m, +Lug_Height, +Dynamic_rolling_radius_mm, +Wheel_Rim_Make_Size +) +SELECT * +FROM crosstab( + 'SELECT unnest(''{front,rear}''::text[]) AS col + , row_number() OVER () + , unnest(ARRAY[front::text,rear::text]) AS val + FROM mmt_staging2.DBSTD_test_engine_RPM_tyre_details_int + ORDER BY generate_series(1,15),2' + ) t ( col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text + ,a_10 text); + + delete from mmt_staging2.DBSTD_test_engine_RPM_tyre_details_block where dummy_f is null; + +execute 'update mmt_staging2.DBSTD_test_engine_RPM_tyre_details_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_engine_RPM_tyre_details_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_engine_RPM_tyre_details_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_engine_RPM_tyre_details_block set make=__make; + update mmt_staging2.DBSTD_test_engine_RPM_tyre_details_block set model=__model; + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_engine_RPM_tyre_details_block'); + + /* block DBSTD_test_test_condition_block */ + perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_test_condition_block',__file_format,__sheet_mnemonic,7); + +insert into mmt_staging2.DBSTD_test_test_condition_block(c1,c2,c3) +select column3 c1,column10 c2,column15 c3 +from mmt_staging2.stg_process_table_dbstd_test a +where a.rank_tag='DBSTD_test_test_condition'; + + +execute 'update mmt_staging2.DBSTD_test_test_condition_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_test_condition_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_test_condition_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_test_condition_block set make=__make; + update mmt_staging2.DBSTD_test_test_condition_block set model=__model; + +update mmt_staging2.dbstd_test_test_condition_block +set c3='B' +where c2='Ballasted'; + +update mmt_staging2.dbstd_test_test_condition_block +set c3='UB' +where c2='Un-ballasted'; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_test_condition_block'); + +/* block DBSTD_test_drawbar_performance_selected_summary_block */ + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_drawbar_performance_selected_summary_block',__file_format,__sheet_mnemonic,8); + +insert into mmt_staging2.DBSTD_test_drawbar_performance_selected_summary_block(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25) +select column3 c1, +column4 c2, +column5 c3, +column6 c4, +column7 c5, +column8 c6, +column9 c7, +column10 c8, +column11 c9, +column12 c10, +column13 c11, +column14 c12, +column15 c13, +column16 c14, +column17 c15, +column18 c16, +column19 c17, +column20 c18, +column21 c19, +column22 c20, +column23 c21, +column24 c22, +column25 c23, +column26 c24, +column27 c25 +from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_drawbar_performance_selected_summary' +and rank>3; + + +execute 'update mmt_staging2.DBSTD_test_drawbar_performance_selected_summary_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_drawbar_performance_selected_summary_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_drawbar_performance_selected_summary_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_drawbar_performance_selected_summary_block set make=__make; + update mmt_staging2.DBSTD_test_drawbar_performance_selected_summary_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_drawbar_performance_selected_summary_block'); + +/* block DBSTD_test_drawbar_performance_gear_performance_block */ + + /* DBSTD_test_drawbar_performance_gear_performance_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_drawbar_performance_gear_performance_block',__file_format,__sheet_mnemonic,9); + +insert into mmt_staging2.DBSTD_test_drawbar_performance_gear_performance_block (c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25) +select column3 c1, +column4 c2, +column5 c3, +column6 c4, +column7 c5, +column8 c6, +column9 c7, +column10 c8, +column11 c9, +column12 c10, +column13 c11, +column14 c12, +column15 c13, +column16 c14, +column17 c15, +column18 c16, +column19 c17, +column20 c18, +column21 c19, +column22 c20, +column23 c21, +column24 c22, +column25 c23, +column26 c24, +column27 c25 +from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_drawbar_performance_gear_performance' +and rank>3; + + +execute 'update mmt_staging2.DBSTD_test_drawbar_performance_gear_performance_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_drawbar_performance_gear_performance_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_drawbar_performance_gear_performance_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_drawbar_performance_gear_performance_block set make=__make; + update mmt_staging2.DBSTD_test_drawbar_performance_gear_performance_block set model=__model; + + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_drawbar_performance_gear_performance_block'); + +/* block DBSTD_test_test_equipment_used_block */ + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_test_equipment_used_block',__file_format,__sheet_mnemonic,10); + + insert into mmt_staging2.DBSTD_test_test_equipment_used_block( s_no,instruments,instruments_no,cali_due_date) +select column3,column4,column8,column12 +from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_test_equipment' +and rank>2; + + + +execute 'update mmt_staging2.DBSTD_test_test_equipment_used_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_test_equipment_used_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_test_equipment_used_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_test_equipment_used_block set make=__make; + update mmt_staging2.DBSTD_test_test_equipment_used_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_test_equipment_used_block'); + +/* block DBSTD_test_measurement_uncertainty_block */ + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_measurement_uncertainty_block',__file_format,__sheet_mnemonic,11); + +insert into mmt_staging2.DBSTD_test_measurement_uncertainty_block(dummy_f) values ('dummy'); + +update mmt_staging2.DBSTD_test_measurement_uncertainty_block set load_cell= +(select column20 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_test_equipment' and trim(column15)='Load cell'); + +update mmt_staging2.DBSTD_test_measurement_uncertainty_block set rpm_meter= +(select column20 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_test_equipment' and trim(column15)='RPM Meter'); + +update mmt_staging2.DBSTD_test_measurement_uncertainty_block set speed= +(select column20 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_test_equipment' and trim(column15)='Speed'); + + +update mmt_staging2.DBSTD_test_measurement_uncertainty_block set fuel_flow_meter= +(select column20 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_test_equipment' and trim(column15)='Fuel Flow meter'); + + + +execute 'update mmt_staging2.DBSTD_test_measurement_uncertainty_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_measurement_uncertainty_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_measurement_uncertainty_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_measurement_uncertainty_block set make=__make; + update mmt_staging2.DBSTD_test_measurement_uncertainty_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_measurement_uncertainty_block'); + + /* block DBSTD_test_tractor_specifications_engine_details_block */ + + /*tractor_specifications_engine_details_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_tractor_specifications_engine_details_block',__file_format,__sheet_mnemonic,12); + +insert into mmt_staging2.DBSTD_test_tractor_specifications_engine_details_block(dummy_f) +values ('dummy'); + +update mmt_staging2.DBSTD_test_tractor_specifications_engine_details_block +set make_in_block=(select column6 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column4)='Make' +) +where dummy_f is not null; + + +update mmt_staging2.DBSTD_test_tractor_specifications_engine_details_block +set type=(select column6 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column4)='Type' +) +where dummy_f is not null; + +update mmt_staging2.DBSTD_test_tractor_specifications_engine_details_block +set model_in_block=(select column6 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column4)='Model' +) +where dummy_f is not null; + + +update mmt_staging2.DBSTD_test_tractor_specifications_engine_details_block +set serial_no=(select column6 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column4)='Serial No' +) +where dummy_f is not null; + + +update mmt_staging2.DBSTD_test_tractor_specifications_engine_details_block +set E_P_ratio=(select column6 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column4)='E P Ratio' +) +where dummy_f is not null; + +update mmt_staging2.DBSTD_test_tractor_specifications_engine_details_block +set rated_speed=(select column6 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column4)='Rated Speed' +) +where dummy_f is not null; + +update mmt_staging2.DBSTD_test_tractor_specifications_engine_details_block +set high_idle=(select column6 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column4)='High Idle' +) +where dummy_f is not null; + +update mmt_staging2.DBSTD_test_tractor_specifications_engine_details_block +set high_idle=(select column6 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column4)='High Idle' +) +where dummy_f is not null; + +update mmt_staging2.DBSTD_test_tractor_specifications_engine_details_block +set low_idle=(select column8 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column4)='High Idle' +) +where dummy_f is not null; + + +execute 'update mmt_staging2.DBSTD_test_tractor_specifications_engine_details_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_tractor_specifications_engine_details_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_tractor_specifications_engine_details_block set function_id='||p_function_id||''; + + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_tractor_specifications_engine_details_block'); + + /* block DBSTD_test_tractor_specifications_cylinders_block */ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_tractor_specifications_cylinders_block',__file_format,__sheet_mnemonic,13); + +insert into mmt_staging2.DBSTD_test_tractor_specifications_cylinders_block(dummy_f) +values ('dummy'); + +update mmt_staging2.DBSTD_test_tractor_specifications_cylinders_block +set number=(select column11 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column9)='Number' +) +where dummy_f is not null; + +update mmt_staging2.DBSTD_test_tractor_specifications_cylinders_block +set stroke=(select column11 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column9)='Stroke' +) +where dummy_f is not null; + +update mmt_staging2.DBSTD_test_tractor_specifications_cylinders_block +set bore=(select column11 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column9)='Bore' +) +where dummy_f is not null; + +update mmt_staging2.DBSTD_test_tractor_specifications_cylinders_block +set capacity=(select column11 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column9)='Capacity' +) +where dummy_f is not null; + + +execute 'update mmt_staging2.DBSTD_test_tractor_specifications_cylinders_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_tractor_specifications_cylinders_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_tractor_specifications_cylinders_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_tractor_specifications_cylinders_block set make=__make; + update mmt_staging2.DBSTD_test_tractor_specifications_cylinders_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_tractor_specifications_cylinders_block'); + +/*block fuel_and_injection_block*/ + perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_tractor_specifications_fuel_and_injection_block',__file_format,__sheet_mnemonic,14); + +insert into mmt_staging2.DBSTD_test_tractor_specifications_fuel_and_injection_block(dummy_f) +values ('dummy'); + +update mmt_staging2.DBSTD_test_tractor_specifications_fuel_and_injection_block +set Make_type_and_model_of_injection_pump=(select column17 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column12)='Make, type and model of injection pump' +) +where dummy_f is not null; + +update mmt_staging2.DBSTD_test_tractor_specifications_fuel_and_injection_block +set capacity_of_fuel_tank_lit=(select column17 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column12)='Capacity of fuel tank lit' +) +where dummy_f is not null; + +update mmt_staging2.DBSTD_test_tractor_specifications_fuel_and_injection_block +set Make_type_and_model_of_injection_pump=(select column17 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column12)='Make, type and model of injection pump' +) +where dummy_f is not null; + +update mmt_staging2.DBSTD_test_tractor_specifications_fuel_and_injection_block +set Manufacturer_production_setting=(select column17 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column12)='Manufacturer’s production setting' +) +where dummy_f is not null; + +update mmt_staging2.DBSTD_test_tractor_specifications_fuel_and_injection_block +set Make_type_and_model_of_injectors=(select column17 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column12)='Make, type and model of injectors' +) +where dummy_f is not null; + +update mmt_staging2.DBSTD_test_tractor_specifications_fuel_and_injection_block +set Make_type_and_model_of_magneto_coil_and_distributor=(select column17 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column12)='Make, type and model of magneto, coil and distributor' +) +where dummy_f is not null; + +update mmt_staging2.DBSTD_test_tractor_specifications_fuel_and_injection_block +set Make_type_and_model_of_carburetor=(select column17 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column12)='Make, type and model of carburetor' +) +where dummy_f is not null; + +update mmt_staging2.DBSTD_test_tractor_specifications_fuel_and_injection_block +set Ignition_or_injection_timing_Manual_or_automatic=(select column17 from mmt_staging2.stg_process_table_dbstd_test a +where rank_tag='DBSTD_test_tractor_specifications' +and trim(column12)='Ignition or injection timing (Manual or automatic)' +) +where dummy_f is not null; + + +execute 'update mmt_staging2.DBSTD_test_tractor_specifications_fuel_and_injection_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_tractor_specifications_fuel_and_injection_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_tractor_specifications_fuel_and_injection_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_tractor_specifications_fuel_and_injection_block set make=__make; + update mmt_staging2.DBSTD_test_tractor_specifications_fuel_and_injection_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_tractor_specifications_fuel_and_injection_block'); + + /*tractor_specifications_cleaner_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_tractor_specifications_cleaner_block',__file_format,__sheet_mnemonic,15); + +insert into mmt_staging2.DBSTD_test_tractor_specifications_cleaner_block(cleaner_type) +values ('Air cleaner'),('Precleaner (if fitted)'); + +update mmt_staging2.DBSTD_test_tractor_specifications_cleaner_block +set type= +(select column23 from mmt_staging2.stg_process_table_dbstd_test a where + rank_tag='DBSTD_test_tractor_specifications' +and column21='Type' and rank=5) +where cleaner_type='Air cleaner'; + +update mmt_staging2.DBSTD_test_tractor_specifications_cleaner_block +set type= +(select column23 from mmt_staging2.stg_process_table_dbstd_test a where +rank_tag='DBSTD_test_tractor_specifications' +and column21='Type' and rank=9) +where cleaner_type='Precleaner (if fitted)'; + + +execute 'update mmt_staging2.DBSTD_test_tractor_specifications_cleaner_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_tractor_specifications_cleaner_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_tractor_specifications_cleaner_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_tractor_specifications_cleaner_block set make=__make; + update mmt_staging2.DBSTD_test_tractor_specifications_cleaner_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_tractor_specifications_cleaner_block'); + + + /*transmission_clutch_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_transmission_clutch_block',__file_format,__sheet_mnemonic,16); + +insert into mmt_staging2.DBSTD_test_transmission_clutch_block(dummy_f) values ('dummy'); + + +update mmt_staging2.DBSTD_test_transmission_clutch_block a +set clutch_type=( +select column6 from mmt_staging2.stg_process_table_dbstd_test b +where b.column3='Type' and rank=2 and b.rank_tag='DBSTD_test_transmission') +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_transmission_clutch_block a +set steering_type=( +select column6 from mmt_staging2.stg_process_table_dbstd_test b +where b.column3='Type' and rank=5 and b.rank_tag='DBSTD_test_transmission') +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_transmission_clutch_block a +set diameter_of_disc_mm=( +select column6 from mmt_staging2.stg_process_table_dbstd_test b +where trim(b.column3)='Diameter of disc, mm' and b.rank_tag='DBSTD_test_transmission') +where dummy_F='dummy'; + + +execute 'update mmt_staging2.DBSTD_test_transmission_clutch_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_transmission_clutch_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_transmission_clutch_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_transmission_clutch_block set make=__make; + update mmt_staging2.DBSTD_test_transmission_clutch_block set model=__model; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_transmission_clutch_block'); + + /*transmission_drawbar_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_transmission_drawbar_block',__file_format,__sheet_mnemonic,17); + +insert into mmt_staging2.DBSTD_test_transmission_drawbar_block(dummy_f) values ('dummy'); + +update mmt_staging2.DBSTD_test_transmission_drawbar_block a +set type=( +select column8 from mmt_staging2.stg_process_table_dbstd_test b +where trim(b.column3)='Type' and rank=7 and b.rank_tag='DBSTD_test_transmission') +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_transmission_drawbar_block a +set Height_above_ground_max_mm=( +select column8 from mmt_staging2.stg_process_table_dbstd_test b +where trim(b.column3)='Height above ground (max) mm' and rank=9 and b.rank_tag='DBSTD_test_transmission') +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_transmission_drawbar_block a +set Height_above_ground_max_mm=( +select column8 from mmt_staging2.stg_process_table_dbstd_test b +where trim(b.column3)='Height above ground (max) mm' and rank=9 and b.rank_tag='DBSTD_test_transmission') +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_transmission_drawbar_block a +set Height_above_ground_min_mm=( +select column8 from mmt_staging2.stg_process_table_dbstd_test b +where trim(b.column3)='Height above ground (min) mm' and rank=11 and b.rank_tag='DBSTD_test_transmission') +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_transmission_drawbar_block a +set Position_related_to_PTO=( +select column8 from mmt_staging2.stg_process_table_dbstd_test b +where trim(b.column3)='Position related to PTO' and rank=13 and b.rank_tag='DBSTD_test_transmission') +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_transmission_drawbar_block a +set Wheel_Base=( +select column8 from mmt_staging2.stg_process_table_dbstd_test b +where trim(b.column3)='Wheel Base' and rank=15 and b.rank_tag='DBSTD_test_transmission') +where dummy_F='dummy'; + + + +execute 'update mmt_staging2.DBSTD_test_transmission_drawbar_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_transmission_drawbar_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_transmission_drawbar_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_transmission_drawbar_block set make=__make; + update mmt_staging2.DBSTD_test_transmission_drawbar_block set model=__model; + + +update mmt_staging2.dbstd_test_transmission_drawbar_block a +set test_condition=b.c3 +from mmt_staging2.dbstd_test_test_condition_block b +where a.file_syspk=b.file_syspk; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_transmission_drawbar_block'); + +/*transmission_speed_chart_desc_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_transmission_speed_chart_desc_block',__file_format,__sheet_mnemonic,18); + +insert into mmt_staging2.DBSTD_test_transmission_speed_chart_desc_block +( +descr) +select column10 +from +mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_transmission' +and rank=1; + + +execute 'update mmt_staging2.DBSTD_test_transmission_speed_chart_desc_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_transmission_speed_chart_desc_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_transmission_speed_chart_desc_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_transmission_speed_chart_desc_block set make=__make; + update mmt_staging2.DBSTD_test_transmission_speed_chart_desc_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_transmission_speed_chart_desc_block'); + +/*transmission_speed_chart_desc_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_transmission_speed_chart_block',__file_format,__sheet_mnemonic,19); + +insert into mmt_staging2.DBSTD_test_transmission_speed_chart_block +(gear,forward,reverse) +select column10,column11, column13 from +mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_transmission' +and rank>=3; + +update mmt_staging2.dbstd_test_transmission_speed_chart_block a +set reverse= b.first_value from (SELECT + syspk, reverse, value_partition, first_value(reverse) over (partition by value_partition order by syspk) +FROM ( + SELECT + syspk, + reverse, + sum(case when reverse is null then 0 else 1 end) over (order by syspk) as value_partition + FROM mmt_staging2.dbstd_test_transmission_speed_chart_block + ORDER BY syspk ASC +) as q) b where a.syspk = b.syspk; + + +execute 'update mmt_staging2.dbstd_test_transmission_speed_chart_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.dbstd_test_transmission_speed_chart_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.dbstd_test_transmission_speed_chart_block set function_id='||p_function_id||''; + update mmt_staging2.dbstd_test_transmission_speed_chart_block set make=__make; + update mmt_staging2.dbstd_test_transmission_speed_chart_block set model=__model; + delete from mmt_staging2.dbstd_test_transmission_speed_chart_block where gear is null; + + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_transmission_speed_chart_block'); + +/*transmission_wheels_in*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_transmission_wheels_block',__file_format,__sheet_mnemonic,20); + + +insert into mmt_staging2.DBSTD_test_transmission_wheels_int(Descriptions,Steered_wheels,Driving_wheel) +select column15,column20,column23 from mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_transmission' +and rank>=3 and rank<=11; + +update mmt_staging2.DBSTD_test_transmission_wheels_int +set Driving_wheel=Steered_wheels +where trim(Descriptions)='Location of driving wheel' +and Driving_wheel =''; + +execute 'update mmt_staging2.DBSTD_test_transmission_wheels_int set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_transmission_wheels_int set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_transmission_wheels_int set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_transmission_wheels_int set make=__make; + update mmt_staging2.DBSTD_test_transmission_wheels_int set model=__model; + + +insert into mmt_staging2.dbstd_test_transmission_wheels_block + ( + dummy_f, + Location_of_driving_wheel, +Make_of_tyres, +types, +size, +Maximum_permissible_load_kg, +Ply_rating, +Track_width_max_mm, +Track_width_min_mm, +Inflation_pressure_kg_cm2 + + ) + SELECT * +FROM crosstab( + 'SELECT unnest(''{steered_wheels,driving_wheel}''::text[]) AS col + , row_number() OVER () + , unnest(ARRAY[steered_wheels::text,driving_wheel::text]) AS val + FROM mmt_staging2.dbstd_test_transmission_wheels_int + ORDER BY generate_series(1,10),2' + ) t ( col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text); + +delete from dbstd_test_transmission_wheels_block where dummy_f is null; + + +execute 'update mmt_staging2.dbstd_test_transmission_wheels_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.dbstd_test_transmission_wheels_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.dbstd_test_transmission_wheels_block set function_id='||p_function_id||''; + update mmt_staging2.dbstd_test_transmission_wheels_block set make=__make; + update mmt_staging2.dbstd_test_transmission_wheels_block set model=__model; + + +insert into mmt_staging2.DBSTD_test_transmission_fuel_lubricant_int( Descriptions,Diesel_BS_IV,Engine_oil,Transmission_oil) +select column15,column18,column20,column23 from mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_transmission' +and rank>=14 and rank<=18; + + +execute 'update mmt_staging2.DBSTD_test_transmission_fuel_lubricant_int set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_transmission_fuel_lubricant_int set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_transmission_fuel_lubricant_int set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_transmission_fuel_lubricant_int set make=__make; + update mmt_staging2.DBSTD_test_transmission_fuel_lubricant_int set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_transmission_wheels_block'); + +/*transmission_fuel_lubricant*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_transmission_fuel_lubricant_block',__file_format,__sheet_mnemonic,21); + + +insert into mmt_staging2.DBSTD_test_transmission_fuel_lubricant_block + ( + dummy_f, + Trade_name, +type, +Octane_Cetane_number, +Viscosity, +Density_at_15C +) +SELECT * +FROM crosstab( + 'SELECT unnest(''{diesel_bs_iv,engine_oil,transmission_oil}''::text[]) AS col + , row_number() OVER () + , unnest(ARRAY[diesel_bs_iv::text,engine_oil::text,transmission_oil::text]) AS val + FROM mmt_staging2.DBSTD_test_transmission_fuel_lubricant_int + ORDER BY generate_series(1,15),2' + ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text); + + delete from DBSTD_test_transmission_fuel_lubricant_block where dummy_f is null; + +execute 'update mmt_staging2.DBSTD_test_transmission_fuel_lubricant_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_transmission_fuel_lubricant_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_transmission_fuel_lubricant_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_transmission_fuel_lubricant_block set make=__make; + update mmt_staging2.DBSTD_test_transmission_fuel_lubricant_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_transmission_fuel_lubricant_block'); + +/*DBSTD_test_remarks_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_remarks_block',__file_format,__sheet_mnemonic,22); + +insert into mmt_staging2.DBSTD_test_remarks_block +( +remarks , +parameter , +acceptance_criteria, +observations +) +select column3,column13,column15,column23 from mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_remarks' +and rank>3 and rank<=5; + + +execute 'update mmt_staging2.DBSTD_test_remarks_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_remarks_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_remarks_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_remarks_block set make=__make; + update mmt_staging2.DBSTD_test_remarks_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_remarks_block'); + +/*DBSTD_test_remarks_footer_block*/ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'DBSTD_test_remarks_footer_block',__file_format,__sheet_mnemonic,23); + +insert into mmt_staging2.DBSTD_test_remarks_footer_block(dummy_f) values ('dummy'); + +update mmt_staging2.DBSTD_test_remarks_footer_block a +set prepared_by=( select column7 from mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_remarks' +and trim(column3)='Prepared by' ) +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_remarks_footer_block a +set reviewed_by=( select column7 from mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_remarks' +and trim(column3)='Reviewed by' ) +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_remarks_footer_block a +set approved_by=( select column7 from mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_remarks' +and trim(column3)='Approved by' ) +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_remarks_footer_block a +set comments=( select column3 from mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_remarks' +and rank=10 ) +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_remarks_footer_block a +set rev1=( select column3 from mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_remarks' +and rank=11 ) +where dummy_F='dummy'; + + +update mmt_staging2.DBSTD_test_remarks_footer_block a +set rev2=( select column9 from mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_remarks' +and rank=11 ) +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_remarks_footer_block a +set rev3=( select column18 from mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_remarks' +and rank=11 ) +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_remarks_footer_block a +set replaces=( select column23 from mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_remarks' +and rank=6) +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_remarks_footer_block a +set revision_no=( select column23 from mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_remarks' +and rank=8) +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_remarks_footer_block a +set date=( select column19 from mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_remarks' +and rank=6) +where dummy_F='dummy'; + +update mmt_staging2.DBSTD_test_remarks_footer_block a +set date=( select column19 from mmt_staging2.stg_process_table_dbstd_test b +where b.rank_tag='DBSTD_test_remarks' +and rank=7 and column9 is not null) +where dummy_F='dummy'; + + +execute 'update mmt_staging2.DBSTD_test_remarks_footer_block set file_syspk='||p_file_syspk||''; + execute 'update mmt_staging2.DBSTD_test_remarks_footer_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.DBSTD_test_remarks_footer_block set function_id='||p_function_id||''; + update mmt_staging2.DBSTD_test_remarks_footer_block set make=__make; + update mmt_staging2.DBSTD_test_remarks_footer_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'DBSTD_test_remarks_footer_block'); + +execute 'update dbstd_test_transmission_fuel_lubricant_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_h1_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_engine_rpm_rpm_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_engine_rpm_engine_to_pto_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_engine_rpm_required_pull_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_engine_rpm_weight_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_engine_rpm_tyre_details_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_test_condition_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_drawbar_performance_selected_summary_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_drawbar_performance_gear_performance_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_test_equipment_used_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_measurement_uncertainty_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_tractor_specifications_engine_details_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_tractor_specifications_cylinders_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_tractor_specifications_fuel_and_injection_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_tractor_specifications_cleaner_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_transmission_clutch_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_transmission_drawbar_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_transmission_speed_chart_desc_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_transmission_speed_chart_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_transmission_wheels_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_transmission_fuel_lubricant_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_remarks_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; +execute 'update dbstd_test_remarks_footer_block set file_format='''||p_file_format||''' , sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +end +$$ LANGUAGE plpgsql; + + + + + + + diff --git a/MMT_SQL/staging2/PTO-GVG_stg2.txt b/MMT_SQL/staging2/PTO-GVG_stg2.txt new file mode 100644 index 0000000..283d334 --- /dev/null +++ b/MMT_SQL/staging2/PTO-GVG_stg2.txt @@ -0,0 +1,351 @@ +drop function if exists mmt_staging2.fn_PTO_GVG_block; +CREATE OR REPLACE FUNCTION mmt_staging2.fn_PTO_GVG_block(p_client_id int,p_function_id int, p_file_format text, +p_sheet_mnemonic text, p_file_syspk int) + RETURNS void AS $$ + declare __make text; + declare __model text; + + declare __client_id int :=p_client_id; + declare __function_id int :=p_function_id; + declare __file_format text :=p_file_format; + declare __sheet_mnemonic text :=p_sheet_mnemonic; + declare __file_syspk int :=p_file_syspk; + + begin + +/************************************************************************************** +Function Name:fn_PTO_GVG_block +Function Desc: This function populates data into staging2 blocks +File Format: PTOBST +Sheet Format: PTOBST_GVG +Creation Date: March 25 2021 +Updation Date: +Author: compegence team +Function Call: select mmt_staging2.fn_PTO_GVG_block(1,1,'PTOBST','PTOBST_GVG',255) +***************************************************************************************/ + +SET search_path TO mmt_staging2; + + +/* rerunnability - delete block tables and update config tables to null */ +truncate table mmt_staging2.stg_specific_table_PTO_GVG; +truncate table mmt_staging2.stg_process_table_PTO_GVG; +truncate table mmt_staging2.PTOBST_GVG_performance_governing_trails_block; + + +execute 'delete from mmt_ods.fw_jobctrl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a +set row_number_start=null, +row_previous_number=null, +row_read_end=null, +run_time=null +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* transfer data from generic to specific for PTOBST */ +execute 'insert into mmt_staging2.stg_specific_table_PTO_GVG +select * from mmt_staging1.mmt_staging_generic_table a +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' +and a.file_syspk='||p_file_syspk||''; + +/* trimming data */ +update mmt_staging2.stg_specific_table_PTO_GVG set column3 = TRIM (TRAILING FROM column3 ); +update mmt_staging2.stg_specific_table_PTO_GVG set column3 = TRIM (LEADING FROM column3 ); + +update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified) ; +update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ; +update mmt_ods.mmt_config set F1_source=F1_modified ; +update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source); +update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source); + +execute 'update mmt_ods.mmt_config a +set row_number_start=(select min(b.row_number) +from mmt_staging2.stg_specific_table_PTO_GVG b +where trim(upper(F1_modified))=trim(upper(column2)) +and b.is_rownumber_fetched is null) +where a.row_number_start is null +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* keyword match in config table*/ +execute 'update mmt_staging2.stg_specific_table_PTO_GVG a +set is_rownumber_fetched=1 +from mmt_ods.mmt_config b +where trim(upper(F1_modified))=trim(upper(column3)) +and b.row_number_start=a.row_number +and is_rownumber_fetched is null +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1 +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a +set row_read_end= (select b.row_number_start +from mmt_ods.mmt_config b +where b.syspk=a.syspk+1 and file_format='''||p_file_format||''' and sheet_mnemonic='''||p_sheet_mnemonic||''' ) +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +/* config file last field update as null otherwise it picks up next format row number*/ +execute 'update mmt_ods.mmt_config a +set row_read_end = null ,run_time=current_timestamp +where f1_modified =''Graphs - for Example'' +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* tagging ranks*/ + +execute 'insert into mmt_staging2.stg_process_table_PTO_GVG +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_PTO_GVG a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Governing Trails on Boost Mode'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_PTO_GVG +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_PTO_GVG a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Graphs - for Example'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +select column3 into __make from mmt_staging2.stg_process_table_PTO_report a +where rank_tag='PTOBST_RPT_test_tractor_specifiactions' and rank=3 ; + +select column4 into __model from mmt_staging2.stg_process_table_PTO_report a +where rank_tag='PTOBST_RPT_test_tractor_specifiactions' and rank=3; + + +/* block PTOBST_GVG_performance_governing_trails_block */ + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_GVG_performance_governing_trails_block',__file_format,__sheet_mnemonic,1); + + +insert into mmt_staging2.PTOBST_GVG_performance_governing_trails_block +( +c2, +c3, +c4, +c5, +c6, +c7, +c8, +c9, +c10, +c11, +c12, +c13, +c14, +c15, +c16, +c17, +c18, +c19, +c20, +c21, +c22, +c23, +c24, +c25, +c26, +c27, +c28, +c29, +c30, +c31, +c32, +c33, +c34, +c35, +c36, +rank +) + +select column2, +column3, +column4, +column5, +column6, +column7, +column8, +column9, +column10, +column11, +column12, +column13, +column14, +column15, +column16, +column17, +column18, +column19, +column20, +column21, +column22, +column23, +column24, +column25, +column26, +column27, +column28, +column29, +column30, +column31, +column32, +column33, +column34, +column35, +column36, +rank + from mmt_staging2.stg_process_table_PTO_GVG a +where rank_tag='PTOBST_GVG_performance_governing_trails'; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block +set test_condition=c2 +where rank=1; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block +set c2=null +where rank=1; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block a +set test_condition= b.first_value from (SELECT + rank, test_condition, value_partition, first_value(test_condition) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + test_condition, + sum(case when test_condition is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_GVG_performance_governing_trails_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block +set c1=c2 where rank=4; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block a +set c1= b.first_value from (SELECT + rank, c1, value_partition, first_value(c1) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + c1, + sum(case when c1 is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_GVG_performance_governing_trails_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block +set c7_1=c7 where rank=4; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block a +set c7_1= b.first_value from (SELECT + rank, c7_1, value_partition, first_value(c7_1) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + c7_1, + sum(case when c7_1 is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_GVG_performance_governing_trails_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block +set c12_1=c12 where rank=4; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block a +set c12_1= b.first_value from (SELECT + rank, c12_1, value_partition, first_value(c12_1) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + c12_1, + sum(case when c12_1 is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_GVG_performance_governing_trails_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block +set c17_1=c17 where rank=4; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block a +set c17_1= b.first_value from (SELECT + rank, c17_1, value_partition, first_value(c17_1) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + c17_1, + sum(case when c17_1 is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_GVG_performance_governing_trails_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block +set c22_1=c22 where rank=4; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block a +set c22_1= b.first_value from (SELECT + rank, c22_1, value_partition, first_value(c22_1) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + c22_1, + sum(case when c22_1 is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_GVG_performance_governing_trails_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block +set c27_1=c27 where rank=4; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block a +set c27_1= b.first_value from (SELECT + rank, c27_1, value_partition, first_value(c27_1) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + c27_1, + sum(case when c27_1 is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_GVG_performance_governing_trails_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block +set c32_1=c32 where rank=4; + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block a +set c32_1= b.first_value from (SELECT + rank, c32_1, value_partition, first_value(c32_1) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + c32_1, + sum(case when c32_1 is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_GVG_performance_governing_trails_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + + +update mmt_staging2.PTOBST_GVG_performance_governing_trails_block +set ods_record=0 where rank in (1,2,3,4); + + execute 'update mmt_staging2.PTOBST_GVG_performance_governing_trails_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_GVG_performance_governing_trails_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_GVG_performance_governing_trails_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_GVG_performance_governing_trails_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_GVG_performance_governing_trails_block set file_syspk='||p_file_syspk||''; + + update mmt_staging2.PTOBST_GVG_performance_governing_trails_block set make=__make; + update mmt_staging2.PTOBST_GVG_performance_governing_trails_block set model=__model; + + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_GVG_performance_governing_trails_block'); + +end +$$ LANGUAGE plpgsql; + diff --git a/MMT_SQL/staging2/PTO-MPM-stg2.txt b/MMT_SQL/staging2/PTO-MPM-stg2.txt new file mode 100644 index 0000000..ce79df7 --- /dev/null +++ b/MMT_SQL/staging2/PTO-MPM-stg2.txt @@ -0,0 +1,168 @@ +drop function if exists mmt_staging2.fn_PTO_MPM_block; +CREATE OR REPLACE FUNCTION mmt_staging2.fn_PTO_MPM_block(p_client_id int,p_function_id int, p_file_format text,p_sheet_mnemonic text, p_file_syspk int) + RETURNS void AS $$ + declare __make text; + declare __model text; + + declare __client_id int :=p_client_id; + declare __function_id int :=p_function_id; + declare __file_format text :=p_file_format; + declare __sheet_mnemonic text :=p_sheet_mnemonic; + declare __file_syspk int :=p_file_syspk; + + + begin + +/************************************************************************************** +Function Name:fn_PTO_MPM_block +Function Desc: This function populates data into staging2 blocks +File Format: PTOBST +Sheet Format: PTOBST_MPM +Creation Date: March 21 2021 +Updation Date: +Author: compegence team +Function Call: select mmt_staging2.fn_PTO_MPM_block(1,1,'PTOBST','PTOBST_MPM',255) +***************************************************************************************/ + +SET search_path TO mmt_staging2; + +/* rerunnability - delete block tables and update config tables to null */ +truncate table mmt_staging2.stg_specific_table_PTO_MPM; +truncate table mmt_staging2.stg_process_table_PTO_MPM; +truncate table mmt_staging2.PTOBST_MPM_performance_boost_natuaral_block; + + +execute 'delete from mmt_ods.fw_jobctrl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +execute 'update mmt_ods.mmt_config a +set row_number_start=null, +row_previous_number=null, +row_read_end=null, +run_time=null +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* transfer data from generic to specific for PTOBST */ +execute 'insert into mmt_staging2.stg_specific_table_PTO_MPM +select * from mmt_staging1.mmt_staging_generic_table a +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' +and a.file_syspk='||p_file_syspk||''; + +/* trimming data */ +update mmt_staging2.stg_specific_table_PTO_MPM set column3 = TRIM (TRAILING FROM column3 ); +update mmt_staging2.stg_specific_table_PTO_MPM set column3 = TRIM (LEADING FROM column3 ); + +update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified) ; +update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ; +update mmt_ods.mmt_config set F1_source=F1_modified ; +update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source); +update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source); + +/* keyword match in config table*/ +execute 'update mmt_ods.mmt_config a +set row_number_start=(select min(b.row_number) +from mmt_staging2.stg_specific_table_PTO_MPM b +where trim(upper(F1_modified))=trim(upper(column2)) +and b.is_rownumber_fetched is null) +where a.row_number_start is null +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* reverese update*/ +execute 'update mmt_staging2.stg_specific_table_PTO_MPM a +set is_rownumber_fetched=1 +from mmt_ods.mmt_config b +where trim(upper(F1_modified))=trim(upper(column3)) +and b.row_number_start=a.row_number +and is_rownumber_fetched is null +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1 +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a +set row_read_end= (select b.row_number_start +from mmt_ods.mmt_config b +where b.syspk=a.syspk+1 and file_format='''||p_file_format||''' and sheet_mnemonic='''||p_sheet_mnemonic||''' ) +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* config file last field update as null otherwise it picks up next format row number*/ +execute 'update mmt_ods.mmt_config a +set row_read_end = null ,run_time=current_timestamp +where f1_modified =''Performance - Boost Mode @ Natural Ambient'' +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* tagging ranks*/ + +execute 'insert into mmt_staging2.stg_process_table_PTO_MPM +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_PTO_MPM a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Performance - Boost Mode @ Natural Ambient'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +select column3 into __make from mmt_staging2.stg_process_table_PTO_report a +where rank_tag='PTOBST_RPT_test_tractor_specifiactions' and rank=3 ; + +select column4 into __model from mmt_staging2.stg_process_table_PTO_report a +where rank_tag='PTOBST_RPT_test_tractor_specifiactions' and rank=3; + +/* block - PTOBST_MPM_performance_boost_natuaral_block*/ + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_MPM_performance_boost_natuaral_block',__file_format,__sheet_mnemonic,1); + +insert into mmt_staging2.PTOBST_MPM_performance_boost_natuaral_block +( +c2, +c3, +c4, +c5, +rank +) +select column2,column3,column4 ,column5,rank from mmt_staging2.stg_process_table_PTO_MPM +where rank_tag='PTOBST_MPM_performance_boost_natuaral'; + + +update mmt_staging2.PTOBST_MPM_performance_boost_natuaral_block +set test_condition=c2 +where rank=1; + +update mmt_staging2.PTOBST_MPM_performance_boost_natuaral_block +set c2=null +where rank=1; + + +update mmt_staging2.PTOBST_MPM_performance_boost_natuaral_block a +set test_condition= b.first_value from (SELECT + rank, test_condition, value_partition, first_value(test_condition) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + test_condition, + sum(case when test_condition is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_MPM_performance_boost_natuaral_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + + +update mmt_staging2.PTOBST_MPM_performance_boost_natuaral_block +set ods_record=0 +where rank in (1,2); + + execute 'update mmt_staging2.PTOBST_MPM_performance_boost_natuaral_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_MPM_performance_boost_natuaral_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_MPM_performance_boost_natuaral_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_MPM_performance_boost_natuaral_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_MPM_performance_boost_natuaral_block set file_syspk='||p_file_syspk||''; + + update mmt_staging2.PTOBST_MPM_performance_boost_natuaral_block set make=__make; + update mmt_staging2.PTOBST_MPM_performance_boost_natuaral_block set model=__model; + + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_MPM_performance_boost_natuaral_block'); + +end +$$ LANGUAGE plpgsql; \ No newline at end of file diff --git a/MMT_SQL/staging2/PTO-PHA-stg2.txt b/MMT_SQL/staging2/PTO-PHA-stg2.txt new file mode 100644 index 0000000..e3aad49 --- /dev/null +++ b/MMT_SQL/staging2/PTO-PHA-stg2.txt @@ -0,0 +1,457 @@ +/* +select mmt_staging2.fn_PTO_PHA_block(1,1,'PTOBST','PTOBST_PHA',183) + +select * from mmt_ods.mmt_config where file_format='PTOBST' and sheet_mnemonic ='PTOBST_PHA' order by syspk +select * from mmt_staging1.mmt_staging_generic_table where file_format='PTOBST' and sheet_mnemonic ='PTOBST_PHA' + +*/ + +drop function if exists mmt_staging2.fn_PTO_PHA_block; +CREATE OR REPLACE FUNCTION mmt_staging2.fn_PTO_PHA_block(p_client_id int,p_function_id int, p_file_format text, +p_sheet_mnemonic text, p_file_syspk int) + RETURNS void AS $$ + declare __make text; + declare __model text; + + declare __client_id int :=p_client_id; + declare __function_id int :=p_function_id; + declare __file_format text :=p_file_format; + declare __sheet_mnemonic text :=p_sheet_mnemonic; + declare __file_syspk int :=p_file_syspk; + + begin + /************************************************************************************** +Function Name:fn_PTO_PHA_block +Function Desc: This function populates data into staging2 blocks +File Format: PTOBST +Sheet Format: PTOBST_PHA +Creation Date: March 21 2021 +Updation Date: +Author: compegence team +Function Call: select mmt_staging2.fn_PTO_PHA_block(1,1,'PTOBST','PTOBST_PHA',255) +***************************************************************************************/ + + +SET search_path TO mmt_staging2; + +/* rerunnability - delete block tables and update config tables to null */ +truncate table mmt_staging2.stg_specific_table_PTO_PHA; +truncate table mmt_staging2.stg_process_table_PTO_PHA; +truncate table mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_int; +truncate table mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_block; +truncate table mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block; +truncate table mmt_staging2.PTOBST_PHA_varying_speed_test_block; +truncate table mmt_staging2.PTOBST_PHA_Engine_oil_consumption_block; + +execute 'delete from mmt_ods.fw_jobctrl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a +set row_number_start=null, +row_previous_number=null, +row_read_end=null, +run_time=null +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* transfer data from generic to specific for PTOBST */ +execute 'insert into mmt_staging2.stg_specific_table_PTO_PHA +select * from mmt_staging1.mmt_staging_generic_table a +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' +and a.file_syspk='||p_file_syspk||''; + +/* trimming data */ +update mmt_staging2.stg_specific_table_PTO_PHA set column3 = TRIM (TRAILING FROM column3 ); +update mmt_staging2.stg_specific_table_PTO_PHA set column3 = TRIM (LEADING FROM column3 ); + +update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified) ; +update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ; +update mmt_ods.mmt_config set F1_source=F1_modified ; +update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source); +update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source); + +/* keyword match in config table*/ +execute 'update mmt_ods.mmt_config a +set row_number_start=(select min(b.row_number) +from mmt_staging2.stg_specific_table_PTO_PHA b +where trim(upper(F1_modified))=trim(upper(column2)) +and b.is_rownumber_fetched is null) +where a.row_number_start is null +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* update config files for row numbers start, end */ +execute 'update mmt_staging2.stg_specific_table_PTO_PHA a +set is_rownumber_fetched=1 +from mmt_ods.mmt_config b +where trim(upper(F1_modified))=trim(upper(column3)) +and b.row_number_start=a.row_number +and is_rownumber_fetched is null +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1 +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a +set row_read_end= (select b.row_number_start +from mmt_ods.mmt_config b +where b.syspk=a.syspk+1 and file_format='''||p_file_format||''' and sheet_mnemonic='''||p_sheet_mnemonic||''' ) +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* config file last field update as null otherwise it picks up next format row number*/ +execute 'update mmt_ods.mmt_config a +set row_read_end = null ,run_time=current_timestamp +where f1_modified =''Engine Oil Consumption'' +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +/* tagging ranks for each block in process table*/ + +execute 'insert into mmt_staging2.stg_process_table_PTO_PHA +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_PTO_PHA a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''KEY Performance Parameters'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_PTO_PHA +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_PTO_PHA a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''2Hrs Max Power Test'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_PTO_PHA +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag from mmt_staging2.stg_specific_table_PTO_PHA a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Varying Speed Test'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_PTO_PHA +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag from mmt_staging2.stg_specific_table_PTO_PHA a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Engine Oil Consumption'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* +execute format('select column6 from mmt_staging2.stg_process_table_PTO a +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' +and rank_tag=''PTO_test_tractor_specifications'' and trim(column4)=''Make''') into __make; + +execute format('select column6 from mmt_staging2.stg_process_table_PTO a +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' +and rank_tag=''PTO_test_tractor_specifications'' and trim(column4)=''Model''') into __model; +*/ + +/* fetching tractor model and make */ +select column3 into __make from mmt_staging2.stg_process_table_PTO_report a +where rank_tag='PTOBST_RPT_test_tractor_specifiactions' and rank=3 ; + +select column4 into __model from mmt_staging2.stg_process_table_PTO_report a +where rank_tag='PTOBST_RPT_test_tractor_specifiactions' and rank=3; + +/* int data loading PTOBST_PHA_key_perfomrance_parameters_int */ +insert into mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_int +( file_syspk,c1,c2,rank) +select file_syspk,column2,column5,rank from mmt_staging2.stg_process_table_PTO_PHA +where rank_tag = 'PTOBST_PHA_KEY_performance_parameters' and rank<>1 +union +select file_syspk,column8,column12,rank from mmt_staging2.stg_process_table_PTO_PHA +where rank_tag = 'PTOBST_PHA_KEY_performance_parameters' and rank<>1 +union +select file_syspk,column13,column16,rank from mmt_staging2.stg_process_table_PTO_PHA +where rank_tag = 'PTOBST_PHA_KEY_performance_parameters' and rank<>1 +union +select file_syspk,column17,column20,rank from mmt_staging2.stg_process_table_PTO_PHA +where rank_tag = 'PTOBST_PHA_KEY_performance_parameters' and rank<>1 +union +select file_syspk,column21,column24 ,rank from mmt_staging2.stg_process_table_PTO_PHA +where rank_tag = 'PTOBST_PHA_KEY_performance_parameters' and rank<>1 +order by rank,column2; + + +delete from mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_int where c1 is null; + +/* block data loading PTOBST_PHA_key_perfomrance_parameters_block */ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_PHA_key_perfomrance_parameters_block',__file_format,__sheet_mnemonic,1); + +insert into mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_block +( +dummy_f, +Ambient_pressure_mm_of_hg , +PTO_gear_ratio , +PTO_power_hp , +Rated_engine_speed , +Test_engineer , +Engine_high_Idle_speed , +PTO_SFC_gm_hp , +Relative_humidity , +Test_bed , +Backup_Torque , +Engine_low_idle_speed , +Exhaust_temperature , +Place , +Specific_gravity_of_Fuel , +back_pressure , +Dyno_Constant , +Engine_oil_temp , +Maximum_Equ_Crankshaft , +Total_run_hrs , +Coolant_temp , +Engine_oil_pressure_bar , +Equ_crankshaft_torque_at_maximum_power , +Test_date +) +SELECT * +FROM crosstab( + 'SELECT unnest(''{c1,c2}''::text[]) AS col + , row_number() OVER () + , unnest(ARRAY[c1::text,c2::text]) AS val + FROM mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_int + ORDER BY generate_series(1,15),2' + ) t (col text,a1 text,a2 text,a3 text,a4 text,a5 text, + a6 text,a7 text,a8 text,a9 text,a10 text,a11 text,a12 text,a13 text,a14 text, + a15 text,a16 text,a17 text,a18 text,a19 text,a20 text,a21 text,a22 text,a23 text); + + +delete from mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_block where dummy_f is null; + +update mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_block set ods_record=0 where dummy_f='c1'; + +update mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_block set test_condition='key_performance_parameters'; + + + execute 'update mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_block set file_syspk='||p_file_syspk||''; + + update mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_block set make=__make; + update mmt_staging2.PTOBST_PHA_key_perfomrance_parameters_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_PHA_key_perfomrance_parameters_block'); + +/* block - PTOBST_PHA_2Hrs_max_power_test_block*/ + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_PHA_2Hrs_max_power_test_block',__file_format,__sheet_mnemonic,2); + +insert into mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block +( +c2, +c3, +c4, +c5, +c6, +c7, +c8, +c9, +c10, +c11, +c12, +c13, +c14, +c15, +c16, +c17, +c18, +c19, +c20, +c21, +c22, +c23, +c24, +c25, +rank +) +select column2, +column3, +column4, +column5, +column6, +column7, +column8, +column9, +column10, +column11, +column12, +column13, +column14, +column15, +column16, +column17, +column18, +column19, +column20, +column21, +column22, +column23, +column24, +column25, +rank +from mmt_staging2.stg_process_table_PTO_PHA +where rank_tag = 'PTOBST_PHA_2Hrs_max_power_test'; + +update mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block +set test_condition=c2 where rank=1; + +update mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block a +set test_condition= b.first_value from (SELECT + rank, test_condition, value_partition, first_value(test_condition) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + test_condition, + sum(case when test_condition is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block set ods_record=0 where +rank in (1,2,3,4); + + execute 'update mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block set file_syspk='||p_file_syspk||''; + + update mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block set make=__make; + update mmt_staging2.PTOBST_PHA_2Hrs_max_power_test_block set model=__model; + + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_PHA_2Hrs_max_power_test_block'); + +/* block - PTOBST_PHA_varying_speed_test_block */ + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_PHA_varying_speed_test_block',__file_format,__sheet_mnemonic,3); + + +insert into mmt_staging2.PTOBST_PHA_varying_speed_test_block +( +c2, +c3, +c4, +c5, +c6, +c7, +c8, +c9, +c10, +c11, +c12, +c13, +c14, +c15, +c16, +c17, +c18, +c19, +c20, +c21, +c22, +c23, +c24, +c25, +rank +) +select column2, +column3, +column4, +column5, +column6, +column7, +column8, +column9, +column10, +column11, +column12, +column13, +column14, +column15, +column16, +column17, +column18, +column19, +column20, +column21, +column22, +column23, +column24, +column25, +rank +from mmt_staging2.stg_process_table_PTO_PHA +where rank_tag='PTOBST_PHA_varying_speed_test'; + +update mmt_staging2.PTOBST_PHA_varying_speed_test_block +set test_condition=c2 where rank=1; + +update mmt_staging2.PTOBST_PHA_varying_speed_test_block a +set test_condition= b.first_value from (SELECT + rank, test_condition, value_partition, first_value(test_condition) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + test_condition, + sum(case when test_condition is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_PHA_varying_speed_test_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_PHA_varying_speed_test_block set ods_record=0 where +rank in (1,2,3,4); + + execute 'update mmt_staging2.PTOBST_PHA_varying_speed_test_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_PHA_varying_speed_test_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_PHA_varying_speed_test_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_PHA_varying_speed_test_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_PHA_varying_speed_test_block set file_syspk='||p_file_syspk||''; + + update mmt_staging2.PTOBST_PHA_varying_speed_test_block set make=__make; + update mmt_staging2.PTOBST_PHA_varying_speed_test_block set model=__model; + + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_PHA_varying_speed_test_block'); + + /* block PTOBST_PHA_Engine_oil_consumption_block*/ + + perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_PHA_Engine_oil_consumption_block',__file_format,__sheet_mnemonic,4); + + insert into mmt_staging2.PTOBST_PHA_Engine_oil_consumption_block +( +c2, +c3,c5, +rank +) +select column2,column3,column5 ,rank from mmt_staging2.stg_process_table_PTO_PHA +where rank_tag='PTOBST_PHA_Engine_oil_consumption'; + +update mmt_staging2.PTOBST_PHA_Engine_oil_consumption_block set ods_record=0 where +rank in (1,2); + + execute 'update mmt_staging2.PTOBST_PHA_Engine_oil_consumption_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_PHA_Engine_oil_consumption_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_PHA_Engine_oil_consumption_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_PHA_Engine_oil_consumption_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_PHA_Engine_oil_consumption_block set file_syspk='||p_file_syspk||''; + + update mmt_staging2.PTOBST_PHA_Engine_oil_consumption_block set make=__make; + update mmt_staging2.PTOBST_PHA_Engine_oil_consumption_block set model=__model; + + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_PHA_Engine_oil_consumption_block'); + + +end +$$ LANGUAGE plpgsql; + + diff --git a/MMT_SQL/staging2/PTO-PNA-stg2.txt b/MMT_SQL/staging2/PTO-PNA-stg2.txt new file mode 100644 index 0000000..fd92b70 --- /dev/null +++ b/MMT_SQL/staging2/PTO-PNA-stg2.txt @@ -0,0 +1,810 @@ +drop function if exists mmt_staging2.fn_PTO_PNA_block; +CREATE OR REPLACE FUNCTION mmt_staging2.fn_PTO_PNA_block(p_client_id int,p_function_id int, p_file_format text, +p_sheet_mnemonic text, p_file_syspk int) + RETURNS void AS $$ + declare __make text; + declare __model text; + + declare __client_id int :=p_client_id; + declare __function_id int :=p_function_id; + declare __file_format text :=p_file_format; + declare __sheet_mnemonic text :=p_sheet_mnemonic; + declare __file_syspk int :=p_file_syspk; + begin + + /************************************************************************************** +Function Name:fn_PTO_PNA_block +Function Desc: This function populates data into staging2 blocks +File Format: PTOBST +Sheet Format: PTOBST_PNA +Creation Date: March 21 2021 +Updation Date: +Author: compegence team +Function Call: select mmt_staging2.fn_PTO_PNA_block(1,1,'PTOBST','PTOBST_PNA',255) +***************************************************************************************/ + + +SET search_path TO mmt_staging2; + +/* rerunnability - delete block tables and update config tables to null */ +truncate table mmt_staging2.stg_specific_table_PTO_PNA; +truncate table mmt_staging2.stg_process_table_PTO_PNA; +truncate table mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_int; +truncate table mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_block; +truncate table mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block; +truncate table mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block; +truncate table mmt_staging2.PTOBST_PNA_varying_speed_test_block; +truncate table mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block; +truncate table mmt_staging2.PTOBST_PNA_varying_load_block; +truncate table mmt_staging2.PTOBST_PNA_smoke_test_block ; + +execute 'delete from mmt_ods.fw_jobctrl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a +set row_number_start=null, +row_previous_number=null, +row_read_end=null, +run_time=null +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +/* transfer data from generic to specific for PTOBST */ +execute 'insert into mmt_staging2.stg_specific_table_PTO_PNA +select * from mmt_staging1.mmt_staging_generic_table a +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' +and a.file_syspk='||p_file_syspk||''; + +/* trimming data */ +update mmt_staging2.stg_specific_table_PTO_PNA set column3 = TRIM (TRAILING FROM column3 ); +update mmt_staging2.stg_specific_table_PTO_PNA set column3 = TRIM (LEADING FROM column3 ); + +update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified) ; +update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ; +update mmt_ods.mmt_config set F1_source=F1_modified ; +update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source); +update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source); + +/* keyword match in config table*/ +execute 'update mmt_ods.mmt_config a +set row_number_start=(select min(b.row_number) +from mmt_staging2.stg_specific_table_PTO_PNA b +where trim(upper(F1_modified))=trim(upper(column2)) +and b.is_rownumber_fetched is null) +where a.row_number_start is null +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +/* update config files for row numbers start, end */ +execute 'update mmt_staging2.stg_specific_table_PTO_PNA a +set is_rownumber_fetched=1 +from mmt_ods.mmt_config b +where trim(upper(F1_modified))=trim(upper(column3)) +and b.row_number_start=a.row_number +and is_rownumber_fetched is null +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1 +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a +set row_read_end= (select b.row_number_start +from mmt_ods.mmt_config b +where b.syspk=a.syspk+1 and file_format='''||p_file_format||''' and sheet_mnemonic='''||p_sheet_mnemonic||''' ) +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +/* config file last field update as null otherwise it picks up next format row number*/ +execute 'update mmt_ods.mmt_config a +set row_read_end = null ,run_time=current_timestamp +where f1_modified =''Smoke Test'' +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* tagging ranks for each block in process table*/ + +execute 'insert into mmt_staging2.stg_process_table_PTO_PNA +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_PTO_PNA a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Key Performance Parameters'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_PTO_PNA +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_PTO_PNA a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Max Power Occurring Test'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_PTO_PNA +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag from mmt_staging2.stg_specific_table_PTO_PNA a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''2Hrs Max Power Test'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_PTO_PNA +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag from mmt_staging2.stg_specific_table_PTO_PNA a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Varying Speed Test - Full Throttle Performance'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_PTO_PNA +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_PTO_PNA a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Part load @ Rated RPM'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_PTO_PNA +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_PTO_PNA a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Varying load @ STD. PTO'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + + +execute 'insert into mmt_staging2.stg_process_table_PTO_PNA +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_PTO_PNA a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Smoke Test'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* fetcching tractor model and make */ +select column3 into __make from mmt_staging2.stg_process_table_PTO_report a +where rank_tag='PTOBST_RPT_test_tractor_specifiactions' and rank=3 ; + +select column4 into __model from mmt_staging2.stg_process_table_PTO_report a +where rank_tag='PTOBST_RPT_test_tractor_specifiactions' and rank=3; + + +/* blocks data loading start - PTOBST_PNA_key_perfomrance_parameters_int */ + +insert into mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_int +( file_syspk,c1,c2,rank) +select file_syspk,column2,column5,rank from mmt_staging2.stg_process_table_PTO_PNA +where rank_tag = 'PTOBST_PNA_key_perfomrance_parameters' and rank<>1 +union +select file_syspk,column8,column12,rank from mmt_staging2.stg_process_table_PTO_PNA +where rank_tag = 'PTOBST_PNA_key_perfomrance_parameters' and rank<>1 +union +select file_syspk,column13,column16,rank from mmt_staging2.stg_process_table_PTO_PNA +where rank_tag = 'PTOBST_PNA_key_perfomrance_parameters' and rank<>1 +union +select file_syspk,column17,column20,rank from mmt_staging2.stg_process_table_PTO_PNA +where rank_tag = 'PTOBST_PNA_key_perfomrance_parameters' and rank<>1 +union +select file_syspk,column21,column24 ,rank from mmt_staging2.stg_process_table_PTO_PNA +where rank_tag = 'PTOBST_PNA_key_perfomrance_parameters' and rank<>1 +order by rank,column2; + + +delete from mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_int where c1 is null; + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_PNA_key_perfomrance_parameters_block',__file_format,__sheet_mnemonic,1); + +insert into mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_block +( +dummy_f, +Ambient_pressure_mm_of_hg , +PTO_gear_ratio , +PTO_power_hp , +Rated_engine_speed , +Test_engineer , +Engine_high_Idle_speed , +PTO_SFC_gm_hp , +Relative_humidity , +Test_bed , +Backup_Torque , +Engine_low_idle_speed , +Exhaust_temperature , +Place , +Specific_gravity_of_Fuel , +back_pressure , +Dyno_Constant , +Engine_oil_temp , +Maximum_Equ_Crankshaft , +Total_run_hrs , +Coolant_temp , +Engine_oil_pressure_bar , +Equ_crankshaft_torque_at_maximum_power , +Test_date +) +SELECT * +FROM crosstab( + 'SELECT unnest(''{c1,c2}''::text[]) AS col + , row_number() OVER () + , unnest(ARRAY[c1::text,c2::text]) AS val + FROM mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_int + ORDER BY generate_series(1,15),2' + ) t (col text,a1 text,a2 text,a3 text,a4 text,a5 text, + a6 text,a7 text,a8 text,a9 text,a10 text,a11 text,a12 text,a13 text,a14 text, + a15 text,a16 text,a17 text,a18 text,a19 text,a20 text,a21 text,a22 text,a23 text); + + +delete from mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_block where dummy_f is null; + +update mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_block set ods_record=0 where dummy_f='c1'; + +update mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_block set test_condition='key_performance_parameters'; + + + execute 'update mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_block set file_syspk='||p_file_syspk||''; + + update mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_block set make=__make; + update mmt_staging2.PTOBST_PNA_key_perfomrance_parameters_block set model=__model; + + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_PNA_key_perfomrance_parameters_block'); + +/* blocks data loading start - PTOBST_PNA_boostmode_maxpower_test_block */ + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_PNA_boostmode_maxpower_test_block',__file_format,__sheet_mnemonic,2); + +insert into mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block +( +c2, +c3, +c4, +c5, +c6, +c7, +c8, +c9, +c10, +c11, +c12, +c13, +c14, +c15, +c16, +c17, +c18, +c19, +c20, +c21, +c22, +c23, +c24, +c25, +rank +) +select column2, +column3, +column4, +column5, +column6, +column7, +column8, +column9, +column10, +column11, +column12, +column13, +column14, +column15, +column16, +column17, +column18, +column19, +column20, +column21, +column22, +column23, +column24, +column25, +rank +from mmt_staging2.stg_process_table_PTO_PNA +where rank_tag = 'PTOBST_PNA_boostmode_maxpower_test'; + +update mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block +set test_condition=c2 where rank=1; + +update mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block a +set test_condition= b.first_value from (SELECT + rank, test_condition, value_partition, first_value(test_condition) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + test_condition, + sum(case when test_condition is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block set ods_record=0 where +rank in (1,2,3,4); + + + execute 'update mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block set file_syspk='||p_file_syspk||''; + + update mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block set make=__make; + update mmt_staging2.PTOBST_PNA_boostmode_maxpower_test_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_PNA_boostmode_maxpower_test_block'); + +/* blocks data loading - PTOBST_PNA_2Hrs_max_power_test_block */ + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_PNA_2Hrs_max_power_test_block',__file_format,__sheet_mnemonic,3); + +insert into mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block +( +c2, +c3, +c4, +c5, +c6, +c7, +c8, +c9, +c10, +c11, +c12, +c13, +c14, +c15, +c16, +c17, +c18, +c19, +c20, +c21, +c22, +c23, +c24, +c25, +rank +) +select column2, +column3, +column4, +column5, +column6, +column7, +column8, +column9, +column10, +column11, +column12, +column13, +column14, +column15, +column16, +column17, +column18, +column19, +column20, +column21, +column22, +column23, +column24, +column25, +rank +from mmt_staging2.stg_process_table_PTO_PNA +where rank_tag = 'PTOBST_PNA_2Hrs_max_power_test'; + +update mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block +set test_condition=c2 where rank=1; + +update mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block a +set test_condition= b.first_value from (SELECT + rank, test_condition, value_partition, first_value(test_condition) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + test_condition, + sum(case when test_condition is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block set ods_record=0 where +rank in (1,2,3,4); + + execute 'update mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block set file_syspk='||p_file_syspk||''; + + update mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block set make=__make; + update mmt_staging2.PTOBST_PNA_2Hrs_max_power_test_block set model=__model; + + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_PNA_2Hrs_max_power_test_block'); + +/* blocks data loading - PTOBST_PNA_varying_speed_test_block */ + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_PNA_varying_speed_test_block',__file_format,__sheet_mnemonic,4); + + insert into mmt_staging2.PTOBST_PNA_varying_speed_test_block +( +c2, +c3, +c4, +c5, +c6, +c7, +c8, +c9, +c10, +c11, +c12, +c13, +c14, +c15, +c16, +c17, +c18, +c19, +c20, +c21, +c22, +c23, +c24, +c25, +rank +) +select column2, +column3, +column4, +column5, +column6, +column7, +column8, +column9, +column10, +column11, +column12, +column13, +column14, +column15, +column16, +column17, +column18, +column19, +column20, +column21, +column22, +column23, +column24, +column25, +rank +from mmt_staging2.stg_process_table_PTO_PNA +where rank_tag='PTOBST_PNA_varying_speed_test'; + +update mmt_staging2.PTOBST_PNA_varying_speed_test_block +set test_condition=c2 where rank=1; + +update mmt_staging2.PTOBST_PNA_varying_speed_test_block a +set test_condition= b.first_value from (SELECT + rank, test_condition, value_partition, first_value(test_condition) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + test_condition, + sum(case when test_condition is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_PNA_varying_speed_test_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_PNA_varying_speed_test_block set ods_record=0 where +rank in (1,2,3,4); + + execute 'update mmt_staging2.PTOBST_PNA_varying_speed_test_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_PNA_varying_speed_test_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_PNA_varying_speed_test_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_PNA_varying_speed_test_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_PNA_varying_speed_test_block set file_syspk='||p_file_syspk||''; + + update mmt_staging2.PTOBST_PNA_varying_speed_test_block set make=__make; + update mmt_staging2.PTOBST_PNA_varying_speed_test_block set model=__model; + + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_PNA_varying_speed_test_block'); + +/* blocks data loading start - PTOBST_PNA_part_load_rated_rpm_block */ + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_PNA_part_load_rated_rpm_block',__file_format,__sheet_mnemonic,5); + + insert into mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block +( +c2, +c3, +c4, +c5, +c6, +c7, +c8, +c9, +c10, +c11, +c12, +c13, +c14, +c15, +c16, +c17, +c18, +c19, +c20, +c21, +c22, +c23, +c24, +c25, +rank +) +select column2, +column3, +column4, +column5, +column6, +column7, +column8, +column9, +column10, +column11, +column12, +column13, +column14, +column15, +column16, +column17, +column18, +column19, +column20, +column21, +column22, +column23, +column24, +column25, +rank +from mmt_staging2.stg_process_table_PTO_PNA +where rank_tag='PTOBST_PNA_part_load_rated_rpm,' ; + + +update mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block set ods_record=0 where +rank in (1,2,3,4); + + +update mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block +set c1 =c3 +where c2 is null and ods_record=1; + +update mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block a +set c1= b.first_value from (SELECT + rank, c1, value_partition, first_value(c1) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + c1, + sum(case when c1 is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block +set test_condition=c2 where rank=1; + +update mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block a +set test_condition= b.first_value from (SELECT + rank, test_condition, value_partition, first_value(test_condition) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + test_condition, + sum(case when test_condition is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + + +update mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block +set c3 = null,ods_record=0 +where c1=c3; + + execute 'update mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block set file_syspk='||p_file_syspk||''; + + update mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block set make=__make; + update mmt_staging2.PTOBST_PNA_part_load_rated_rpm_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_PNA_part_load_rated_rpm_block'); + +/* block loading data PTOBST_PNA_varying_load_block*/ + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_PNA_varying_load_block',__file_format,__sheet_mnemonic,6); + + insert into mmt_staging2.PTOBST_PNA_varying_load_block +( +c2, +c3, +c4, +c5, +c6, +c7, +c8, +c9, +c10, +c11, +c12, +c13, +c14, +c15, +c16, +c17, +c18, +c19, +c20, +c21, +c22, +c23, +c24, +c25, +rank +) +select column2, +column3, +column4, +column5, +column6, +column7, +column8, +column9, +column10, +column11, +column12, +column13, +column14, +column15, +column16, +column17, +column18, +column19, +column20, +column21, +column22, +column23, +column24, +column25, +rank +from mmt_staging2.stg_process_table_PTO_PNA +where rank_tag='PTOBST_PNA_varying_load,'; + + +update mmt_staging2.PTOBST_PNA_varying_load_block set ods_record=0 where +rank in (1,2,3,4); + + +update mmt_staging2.PTOBST_PNA_varying_load_block +set c1 =c3 +where c2 is null and ods_record=1; + +update mmt_staging2.PTOBST_PNA_varying_load_block a +set c1= b.first_value from (SELECT + rank, c1, value_partition, first_value(c1) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + c1, + sum(case when c1 is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_PNA_varying_load_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_PNA_varying_load_block +set test_condition=c2 where rank=1; + +update mmt_staging2.PTOBST_PNA_varying_load_block a +set test_condition= b.first_value from (SELECT + rank, test_condition, value_partition, first_value(test_condition) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + test_condition, + sum(case when test_condition is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_PNA_varying_load_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_PNA_varying_load_block +set c3 = null,ods_record=0 +where c1=c3; + + + execute 'update mmt_staging2.PTOBST_PNA_varying_load_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_PNA_varying_load_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_PNA_varying_load_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_PNA_varying_load_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_PNA_varying_load_block set file_syspk='||p_file_syspk||''; + + update mmt_staging2.PTOBST_PNA_varying_load_block set make=__make; + update mmt_staging2.PTOBST_PNA_varying_load_block set model=__model; + + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_PNA_varying_load_block'); + + /* block data loading PTOBST_PNA_smoke_test_block*/ + + perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_PNA_smoke_test_block',__file_format,__sheet_mnemonic,7); + + insert into mmt_staging2.PTOBST_PNA_smoke_test_block +( +c2, +c3, +c4, +c5, +c6, +c7, +rank +) +select +column2, +column3,column4,column5, +column6,column7 ,rank +from mmt_staging2.stg_process_table_PTO_PNA where rank_tag='PTOBST_PNA_smoke_test'; + + +update mmt_staging2.PTOBST_PNA_smoke_test_block +set test_condition=c2 where rank=1; + +update mmt_staging2.PTOBST_PNA_smoke_test_block a +set test_condition= b.first_value from (SELECT + rank, test_condition, value_partition, first_value(test_condition) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + test_condition, + sum(case when test_condition is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_PNA_smoke_test_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_PNA_smoke_test_block +set ods_record=0 where rank in (1,2,3); + + execute 'update mmt_staging2.PTOBST_PNA_smoke_test_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_PNA_smoke_test_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_PNA_smoke_test_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_PNA_smoke_test_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_PNA_smoke_test_block set file_syspk='||p_file_syspk||''; + + update mmt_staging2.PTOBST_PNA_smoke_test_block set make=__make; + update mmt_staging2.PTOBST_PNA_smoke_test_block set model=__model; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_PNA_smoke_test_block'); + +end +$$ LANGUAGE plpgsql; diff --git a/MMT_SQL/staging2/PTO-RPT-stg2.txt b/MMT_SQL/staging2/PTO-RPT-stg2.txt new file mode 100644 index 0000000..4669dd2 --- /dev/null +++ b/MMT_SQL/staging2/PTO-RPT-stg2.txt @@ -0,0 +1,325 @@ +drop function if exists mmt_staging2.fn_PTO_report_block; +CREATE OR REPLACE FUNCTION mmt_staging2.fn_PTO_report_block(p_client_id int,p_function_id int, p_file_format text, +p_sheet_mnemonic text, p_file_syspk int) + RETURNS void AS $$ + declare __make text; + declare __model text; + + declare __client_id int :=p_client_id; + declare __function_id int :=p_function_id; + declare __file_format text :=p_file_format; + declare __sheet_mnemonic text :=p_sheet_mnemonic; + declare __file_syspk int :=p_file_syspk; + begin + +/*********************************************************************************** +Function Name:fn_PTO_PNA_block +Function Desc: This function populates data into staging2 blocks +File Format: PTOBST +Sheet Format: PTOBST_RPT +Creation Date: March 21 2021 +Updation Date: +Author: compegence team +Function Call: select mmt_staging2.fn_PTO_report_block(1,1,'PTOBST','PTOBST_RPT',255) +************************************************************************************/ + + +SET search_path TO mmt_staging2; + +/* rerunnability - delete block tables and update config tables to null */ +truncate table mmt_staging2.stg_specific_table_PTO_report; +truncate table mmt_staging2.stg_process_table_PTO_report; +truncate table mmt_staging2.PTOBST_RPT_tractor_specs_block; +truncate table mmt_staging2.PTOBST_RPT_PTO_performance_report_block; +truncate table mmt_staging2.PTOBST_RPT_MMTKeyword1_block; +truncate table mmt_staging2.PTOBST_RPT_MMTKeyword2_block; +truncate table mmt_staging2.PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block; + + +execute 'delete from mmt_ods.fw_jobctrl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a +set row_number_start=null, +row_previous_number=null, +row_read_end=null, +run_time=null +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* transfer data from generic to specific for PTOBST */ +execute 'insert into mmt_staging2.stg_specific_table_PTO_report +select * from mmt_staging1.mmt_staging_generic_table a +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' +and a.file_syspk='||p_file_syspk||''; + +/* trimming data */ +update mmt_staging2.stg_specific_table_PTO_report set column3 = TRIM (TRAILING FROM column3 ); +update mmt_staging2.stg_specific_table_PTO_report set column3 = TRIM (LEADING FROM column3 ); + +update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified) ; +update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ; +update mmt_ods.mmt_config set F1_source=F1_modified ; +update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source); +update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source); + +/* keyword match in config table*/ +execute 'update mmt_ods.mmt_config a +set row_number_start=(select min(b.row_number) +from mmt_staging2.stg_specific_table_PTO_report b +where trim(upper(F1_modified))=trim(upper(column3)) +and b.is_rownumber_fetched is null) +where a.row_number_start is null +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* reverese update in process table for match*/ +execute 'update mmt_staging2.stg_specific_table_PTO_report a +set is_rownumber_fetched=1 +from mmt_ods.mmt_config b +where trim(upper(F1_modified))=trim(upper(column3)) +and b.row_number_start=a.row_number +and is_rownumber_fetched is null +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* update config files for row numbers start, end */ +execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1 +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'update mmt_ods.mmt_config a +set row_read_end= (select b.row_number_start +from mmt_ods.mmt_config b +where b.syspk=a.syspk+1 and file_format='''||p_file_format||''' and sheet_mnemonic='''||p_sheet_mnemonic||''' ) +where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* config file last field update as null otherwise it picks up next format row number*/ +execute 'update mmt_ods.mmt_config a +set row_read_end = null ,run_time=current_timestamp +where f1_modified =''PTO Performance Test Observations Summary'' +and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* tagging ranks for each block in process table*/ +execute 'insert into mmt_staging2.stg_process_table_PTO_report +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_PTO_report a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''Test Tractor Specifiactions'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_PTO_report +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_PTO_report a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''PTO Performance Report'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_PTO_report +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag from mmt_staging2.stg_specific_table_PTO_report a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''MMTKeyword1'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_PTO_report +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag from mmt_staging2.stg_specific_table_PTO_report a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''MMTKeyword2'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +execute 'insert into mmt_staging2.stg_process_table_PTO_report +select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag +from mmt_staging2.stg_specific_table_PTO_report a +join mmt_ods.mmt_config b +on a.row_number >=row_number_start +and (a.row_number< row_read_end or row_read_end is null) +and f1_modified=''PTO Performance Test Observations Summary'' +and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; + +/* fetching tractor model and make */ +select column3 into __make from mmt_staging2.stg_process_table_PTO_report a +where rank_tag='PTOBST_RPT_test_tractor_specifiactions' and rank=3 ; + +select column4 into __model from mmt_staging2.stg_process_table_PTO_report a +where rank_tag='PTOBST_RPT_test_tractor_specifiactions' and rank=3; + + +/* blocks data loading start - PTOBST_RPT_tractor_specs_block */ + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_RPT_tractor_specs_block',__file_format,__sheet_mnemonic,1); + +insert into mmt_staging2.PTOBST_RPT_tractor_specs_block +(make,model,tractor_HP,rated_rpm,configuration,transmission_type,wheel_drive_type,FIP_type,rank) +select column3,column4,column5,column6,column7,column8,column9,column10,rank +from mmt_staging2.stg_process_table_PTO_report where rank_tag='PTOBST_RPT_test_tractor_specifiactions' +and rank=3; + +execute 'update mmt_staging2.PTOBST_RPT_tractor_specs_block set file_syspk='||p_file_syspk||''; + +update mmt_staging2.PTOBST_RPT_tractor_specs_block a +set date= date '1899-12-30' + column12::int * interval '1' day +from mmt_staging2.stg_process_table_PTO_report b +where b.rank_tag='PTOBST_RPT_test_tractor_specifiactions' +and b.rank=1 +and a.file_syspk=b.file_syspk ; + +update mmt_staging2.PTOBST_RPT_tractor_specs_block a +set steering_type=column3,Engine_to_PTO_ratio= column4 +from mmt_staging2.stg_process_table_PTO_report b +where b.rank_tag='PTOBST_RPT_test_tractor_specifiactions' +and b.rank=5 +and a.file_syspk=b.file_syspk; + + update mmt_staging2.PTOBST_RPT_tractor_specs_block set make=__make; + update mmt_staging2.PTOBST_RPT_tractor_specs_block set model=__model; + execute 'update mmt_staging2.PTOBST_RPT_tractor_specs_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_RPT_tractor_specs_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_RPT_tractor_specs_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_RPT_tractor_specs_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_RPT_tractor_specs_block'); + +/* blocks data loading - PTOBST_RPT_PTO_performance_report_block */ + +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_RPT_PTO_performance_report_block',__file_format,__sheet_mnemonic,2); + +insert into mmt_staging2.PTOBST_RPT_PTO_performance_report_block +( c2,c3,c4,c5,c6,c7,c8,c9,c10,rank) +select column2,column3,column4,column5,column6,column7,column8,column9,column10,rank +from mmt_staging2.stg_process_table_PTO_report +where rank_tag='PTOBST_RPT_PTO_performance_report'; + + +update mmt_staging2.PTOBST_RPT_PTO_performance_report_block +set c2=c3; + +update mmt_staging2.PTOBST_RPT_PTO_performance_report_block +set c2=null +where c2 like 'i%'; + +update mmt_staging2.PTOBST_RPT_PTO_performance_report_block +set c2=null +where c2 like 'v%'; + +update mmt_staging2.PTOBST_RPT_PTO_performance_report_block a +set c2= b.first_value from (SELECT + rank, c2, value_partition, first_value(c2) over (partition by value_partition order by rank) +FROM ( + SELECT + rank, + c2, + sum(case when c2 is null then 0 else 1 end) over (order by rank) as value_partition + FROM mmt_staging2.PTOBST_RPT_PTO_performance_report_block + ORDER BY rank ASC +) as q) b where a.rank = b.rank ; + +update mmt_staging2.PTOBST_RPT_PTO_performance_report_block +set c3 =null +where c2=c3; + +update mmt_staging2.PTOBST_RPT_PTO_performance_report_block +set ods_record=0 where rank in (1,2,3); + + +update mmt_staging2.PTOBST_RPT_PTO_performance_report_block set ods_record=0 where c3 is null +and c2 in( +select c2 from mmt_staging2.PTOBST_RPT_PTO_performance_report_block group by c2 having count(*)>1 +); + + update mmt_staging2.PTOBST_RPT_PTO_performance_report_block set make=__make; + update mmt_staging2.PTOBST_RPT_PTO_performance_report_block set model=__model; + execute 'update mmt_staging2.PTOBST_RPT_PTO_performance_report_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_RPT_PTO_performance_report_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_RPT_PTO_performance_report_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_RPT_PTO_performance_report_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_RPT_PTO_performance_report_block set file_syspk='||p_file_syspk||''; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_RPT_PTO_performance_report_block'); + + /* block loading data - PTOBST_RPT_MMTKeyword1_block*/ + + perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_RPT_MMTKeyword1_block',__file_format,__sheet_mnemonic,3); + + insert into mmt_staging2.PTOBST_RPT_MMTKeyword1_block +( c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,rank) +select column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12,rank +from mmt_staging2.stg_process_table_PTO_report +where rank_tag='PTOBST_RPT_MMTKeyword1'; + + +update mmt_staging2.PTOBST_RPT_MMTKeyword1_block set ods_record=0 where rank in (1,2); + + update mmt_staging2.PTOBST_RPT_MMTKeyword1_block set make=__make; + update mmt_staging2.PTOBST_RPT_MMTKeyword1_block set model=__model; + execute 'update mmt_staging2.PTOBST_RPT_MMTKeyword1_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_RPT_MMTKeyword1_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_RPT_MMTKeyword1_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_RPT_MMTKeyword1_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_RPT_MMTKeyword1_block set file_syspk='||p_file_syspk||''; + + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_RPT_MMTKeyword1_block'); + + /* block loading data PTOBST_RPT_MMTKeyword2_block */ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_RPT_MMTKeyword2_block',__file_format,__sheet_mnemonic,4); + +insert into mmt_staging2.PTOBST_RPT_MMTKeyword2_block +( c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,rank) +select column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12,rank +from mmt_staging2.stg_process_table_PTO_report +where rank_tag='PTOBST_RPT_MMTKeyword2'; + + +update mmt_staging2.PTOBST_RPT_MMTKeyword2_block set ods_record=0 where rank in (1,2); + + + update mmt_staging2.PTOBST_RPT_MMTKeyword2_block set make=__make; + update mmt_staging2.PTOBST_RPT_MMTKeyword2_block set model=__model; + execute 'update mmt_staging2.PTOBST_RPT_MMTKeyword2_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_RPT_MMTKeyword2_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_RPT_MMTKeyword2_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_RPT_MMTKeyword2_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_RPT_MMTKeyword2_block set file_syspk='||p_file_syspk||''; + + perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_RPT_MMTKeyword2_block'); + +/* block loading data PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block */ +perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk, +'PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block',__file_format,__sheet_mnemonic,5); + + +insert into mmt_staging2.PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block +( c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,rank) +select column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12,rank +from mmt_staging2.stg_process_table_PTO_report +where rank_tag='PTOBST_RPT_PTO_Performance_Test_Observations_Summary'; + + + +update mmt_staging2.PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block set ods_record=0 where rank in (1,2); + + update mmt_staging2.PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block set make=__make; + update mmt_staging2.PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block set model=__model; + execute 'update mmt_staging2.PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block set client_id='||p_client_id||''; + execute 'update mmt_staging2.PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block set function_id='||p_function_id||''; + execute 'update mmt_staging2.PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block set file_format='''||p_file_format||''''; + execute 'update mmt_staging2.PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block set sheet_mnemonic='''||p_sheet_mnemonic||''''; + execute 'update mmt_staging2.PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block set file_syspk='||p_file_syspk||''; + +perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block'); + +/* final update */ + +update mmt_staging2.PTOBST_RPT_PTO_performance_report_block set test_condition='PTO performance report'; +update mmt_staging2.PTOBST_RPT_PTO_performance_report_block set test_condition='PTO performance report'; +update mmt_staging2.PTOBST_RPT_PTO_Performance_Test_Observations_Summary_block set test_condition='PTO_Performance_Test_Observations_Summary'; + +end +$$ LANGUAGE plpgsql; diff --git a/MMT_SQL/staging2/budni_dbp_execute.sql b/MMT_SQL/staging2/budni_dbp_execute.sql deleted file mode 100644 index a1f18a1..0000000 --- a/MMT_SQL/staging2/budni_dbp_execute.sql +++ /dev/null @@ -1,199 +0,0 @@ -drop function if exists mmt_staging2.fn_BUDNI_DBP_Block ; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_BUDNI_DBP_Block(p_client_id int,p_function_id int, p_file_format text, -p_sheet_mnemonic text, p_file_syspk int) - RETURNS void AS $$ - declare __make text; - declare __model text; - begin - -SET search_path TO mmt_staging2; - -delete from mmt_staging2.BUDNI_DBP_Spec_H1_Block; -delete from mmt_staging2.BUDNI_DBP_Drawbar_Perf_Block; -delete from mmt_staging2.stg_specific_table_budni_dbp; -delete from mmt_staging2.stg_process_table_budni_dbp; - -execute 'update mmt_ods.mmt_config a -set row_number_start=null, -row_previous_number=null, -row_read_end=null, -run_time=null -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - - -execute 'insert into mmt_staging2.stg_specific_table_budni_dbp -select * from mmt_staging1.mmt_staging_generic_table a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.file_syspk='||p_file_syspk||''; - - -execute 'update mmt_staging2.stg_specific_table_budni_dbp set column2 = TRIM (TRAILING FROM column2 )'; -execute 'update mmt_staging2.stg_specific_table_budni_dbp set column2 = TRIM (LEADING FROM column2 )'; - - -execute 'update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified)'; -execute 'update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified)' ; -execute 'update mmt_ods.mmt_config set F1_source=F1_modified' ; -execute 'update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source)'; -execute 'update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source)' ; - - -execute 'update mmt_ods.mmt_config a -set row_number_start=(select min(b.row_number) -from mmt_staging2.stg_specific_table_budni_dbp b -where trim(upper(F1_source))= trim(upper(column3)) -and b.is_rownumber_fetched is null) -where a.row_number_start is null -and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_staging2.stg_specific_table_budni_dbp a -set is_rownumber_fetched=1 -from mmt_ods.mmt_config b -where trim(upper(F1_source))= trim(upper(column3)) -and b.row_number_start=a.row_number -and is_rownumber_fetched is null and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1 -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -execute 'update mmt_ods.mmt_config a -set row_read_end= (select b.row_number_start -from mmt_ods.mmt_config b -where b.syspk=a.syspk+1 ) -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a -set row_read_end = null -where f1_modified =''Tractor Drawbar Performance Report'' -and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a -set run_time=current_timestamp -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -execute 'insert into mmt_staging2.stg_process_table_budni_dbp -select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_budni_dbp a -join mmt_ods.mmt_config b -on a.row_number >row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Tractor Specifiactions'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - - -execute 'insert into mmt_staging2.stg_process_table_budni_dbp -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_budni_dbp a -join mmt_ods.mmt_config b -on a.row_number >row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Tractor Drawbar Performance Report.'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - -delete from mmt_staging2.stg_process_table_budni_dbp where row_number between 37 and 42; - -select column3 into __make from mmt_staging2.stg_process_table_budni_dbp a -where rank_tag='BUDNI_DBP_Spec_H1' and rank=2; - -select column4 into __model from mmt_staging2.stg_process_table_budni_dbp a -where rank_tag='BUDNI_DBP_Spec_H1' and rank=2; - - - - -insert into mmt_staging2.BUDNI_DBP_Spec_H1_Block -( -column2,column3,column4,column5,column6,column7, -column8,column9,column10,column11,column12,column13, -column14,column15,rank -) -select -column2,column3,column4,column5,column6,column7,column8,column9,column10, -column11,column12,column13,column14,column15,rank -from mmt_staging2.stg_process_table_budni_dbp -where rank_tag='BUDNI_DBP_Spec_H1'; - - -update mmt_staging2.BUDNI_DBP_Spec_H1_Block -set ods_record=0 where rank in -(select distinct first_value(b.rank) -over (partition by b.column2 order by b.syspk) from mmt_staging2.BUDNI_DBP_Spec_H1_Block b); - - -execute 'update mmt_staging2.BUDNI_DBP_Spec_H1_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -execute 'insert into mmt_staging2.BUDNI_DBP_Drawbar_Perf_Block -( -column2,column3,column4,column5,column6,column7, -column8,column9,column10,column11,column12,column13, -column14,column15,column16,column17,column18,column19,rank -) -select -column2,column3,column4,column5,column6,column7, -column8,column9,column10,column11,column12,column13,column14, -column15,column16,column17,column18,column19,rank -from mmt_staging2.stg_process_table_budni_dbp a -where rank_tag=''BUDNI_DBP_Drawbar_Perf'''; - - -update mmt_staging2.BUDNI_DBP_Drawbar_Perf_Block set make=__make,model=__model; -execute 'update mmt_staging2.BUDNI_DBP_Drawbar_Perf_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - - - -update mmt_staging2.BUDNI_DBP_Drawbar_Perf_Block -set column2= column3 where column3 like 'i%'; - -update mmt_staging2.BUDNI_DBP_Drawbar_Perf_Block -set column3=null -where column3 like 'i%'; - -update mmt_staging2.BUDNI_DBP_Drawbar_Perf_Block a - set column2= b.first_value from (SELECT -rank, column2, value_partition, first_value(column2) over (partition by value_partition order by rank) -FROM ( -SELECT -rank, -column2, -sum(case when column2 is null then 0 else 1 end) over (order by rank) as value_partition - FROM mmt_staging2.BUDNI_DBP_Drawbar_Perf_Block -ORDER BY rank ASC -) as q) b where a.rank = b.rank; - - - - - -update mmt_staging2.BUDNI_DBP_Drawbar_Perf_Block -set ods_record=0 where column4 is null or -rank in -(select distinct first_value(b.rank) -over (partition by b.column2 order by b.syspk) from mmt_staging2.BUDNI_DBP_Drawbar_Perf_Block b); - - - -end -$$ LANGUAGE plpgsql; - - -select mmt_staging2.fn_BUDNI_DBP_Block(20,1,'BUDNI','BUDNI_DBP',182); - - diff --git a/MMT_SQL/staging2/budni_pto_execute.sql b/MMT_SQL/staging2/budni_pto_execute.sql deleted file mode 100644 index 9b01fef..0000000 --- a/MMT_SQL/staging2/budni_pto_execute.sql +++ /dev/null @@ -1,283 +0,0 @@ -drop function if exists mmt_staging2.fn_BUDNI_PTO_block; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_BUDNI_PTO_block(p_client_id int,p_function_id int, p_file_format text, -p_sheet_mnemonic text, p_file_syspk int) - RETURNS text AS $$ - declare __make text; - declare __model text; - begin - -SET search_path TO mmt_staging2; - -delete from mmt_staging2.stg_specific_table_BUDNI_PTO; -delete from mmt_staging2.stg_process_table_BUDNI_PTO; -delete from mmt_staging2.BUDNI_PTO_Spec_H1_Block; -delete from mmt_staging2.BUDNI_PTO_Perf_Report_block; -delete from mmt_staging2.BUDNI_PTO_MMTKeyword1_Block; -delete from mmt_staging2.BUDNI_PTO_MMTKeyword2_Block; -delete from mmt_staging2.BUDNI_PTO_Summary_Block; - -/* rerun */ -execute 'update mmt_ods.mmt_config a -set row_number_start=null, -row_previous_number=null, -row_read_end=null, -run_time=null -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -execute 'insert into mmt_staging2.stg_specific_table_budni_pto -select * from mmt_staging1.mmt_staging_generic_table a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.file_syspk='||p_file_syspk||''; - - -update mmt_staging2.stg_specific_table_budni_pto set column3 = TRIM (TRAILING FROM column3 ); -update mmt_staging2.stg_specific_table_budni_pto set column3 = TRIM (LEADING FROM column3 ); - -update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified) ; -update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ; -update mmt_ods.mmt_config set F1_source=F1_modified ; -update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source); -update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source); - -/* keyword match */ -execute 'update mmt_ods.mmt_config a -set row_number_start=(select min(b.row_number) -from mmt_staging2.stg_specific_table_budni_pto b -where trim(upper(F1_modified))=trim(upper(column3)) -and b.is_rownumber_fetched is null) -where a.row_number_start is null -and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -/* reverese update */ -execute 'update mmt_staging2.stg_specific_table_budni_pto a -set is_rownumber_fetched=1 -from mmt_ods.mmt_config b -where trim(upper(F1_modified))=trim(upper(column3)) -and b.row_number_start=a.row_number -and is_rownumber_fetched is null -and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1 -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a -set row_read_end= (select b.row_number_start -from mmt_ods.mmt_config b -where b.syspk=a.syspk+1 and file_format='''||p_file_format||''' and sheet_mnemonic='''||p_sheet_mnemonic||''' ) -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -/* last field */ -execute 'update mmt_ods.mmt_config a -set row_read_end = null ,run_time=current_timestamp -where f1_modified =''PTO Performance Test Observations Summary'' -and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -/* tagging ranks*/ -execute 'insert into mmt_staging2.stg_process_table_budni_pto -select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_budni_pto a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Tractor Specifiactions'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'insert into mmt_staging2.stg_process_table_budni_pto -select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_budni_pto a -join mmt_ods.mmt_config b -on a.row_number >row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''PTO Performance Report'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'insert into mmt_staging2.stg_process_table_budni_pto -select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag from mmt_staging2.stg_specific_table_budni_pto a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''MMTKeyword1'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'insert into mmt_staging2.stg_process_table_budni_pto -select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag from mmt_staging2.stg_specific_table_budni_pto a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''MMTKeyword2'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'insert into mmt_staging2.stg_process_table_budni_pto -select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_budni_pto a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''PTO Performance Test Observations Summary'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -delete from mmt_staging2.stg_process_table_budni_pto where row_number between 42 and 47; - -select column3 into __make from mmt_staging2.stg_process_table_budni_pto a -where rank_tag='BUDNI_PTO_Spec_H1' and rank=3 ; - -select column4 into __model from mmt_staging2.stg_process_table_budni_pto a -where rank_tag='BUDNI_PTO_Spec_H1' and rank=3; - -/* blocks */ -insert into mmt_staging2.BUDNI_PTO_Spec_H1_block -(make,model,tractor_HP,rated_rpm,configuration,transmission_type,wheel_drive_type,FIP_type,rank) -select column3,column4,column5,column6,column7,column8,column9,column10,rank -from mmt_staging2.stg_process_table_budni_pto where rank_tag='BUDNI_PTO_Spec_H1' -and rank=3; - - -execute 'update mmt_staging2.BUDNI_PTO_Spec_H1_block set file_syspk='||p_file_syspk||''; - -update mmt_staging2.BUDNI_PTO_Spec_H1_block a -set date= date '1899-12-30' + column12::int * interval '1' day -from mmt_staging2.stg_process_table_budni_pto b -where b.rank_tag='BUDNI_PTO_Spec_H1' -and b.rank=1 -and a.file_syspk=b.file_syspk ; - - - -update mmt_staging2.BUDNI_PTO_Spec_H1_block a -set steering_type=column3,Engine_to_PTO_ratio= column4 -from mmt_staging2.stg_process_table_budni_pto b -where b.rank_tag='BUDNI_PTO_Spec_H1' -and b.rank=5 -and a.file_syspk=b.file_syspk; - - update mmt_staging2.BUDNI_PTO_Spec_H1_block set make=__make, model=__model; - execute 'update mmt_staging2.BUDNI_PTO_Spec_H1_block set -client_id='||p_client_id||', -function_id='||p_function_id||', - file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''', - file_syspk='||p_file_syspk||''; - - -/*block */ -insert into mmt_staging2.BUDNI_PTO_Perf_Report_block -( column2,column3,column4,column5,column6,column7,column8,column9,column10,rank) -select column2,column3,column4,column5,column6,column7,column8,column9,column10,rank -from mmt_staging2.stg_process_table_budni_pto -where rank_tag='BUDNI_PTO_Perf_Report'; - - -update mmt_staging2.BUDNI_PTO_Perf_Report_block -set column2=column3 where column2 is null; - -update mmt_staging2.BUDNI_PTO_Perf_Report_block -set column2=null -where column2 like 'i%'; - -update mmt_staging2.BUDNI_PTO_Perf_Report_block -set column2=null -where column2 like 'v%'; - -update mmt_staging2.BUDNI_PTO_Perf_Report_block a -set column2= b.first_value from (SELECT - rank, column2, value_partition, first_value(column2) over (partition by value_partition order by rank) -FROM ( - SELECT - rank, - column2, - sum(case when column2 is null then 0 else 1 end) over (order by rank) as value_partition - FROM mmt_staging2.BUDNI_PTO_Perf_Report_block - ORDER BY rank ASC -) as q) b where a.rank = b.rank ; - -update mmt_staging2.BUDNI_PTO_Perf_Report_block -set column3 =null -where column2=column3; - -update mmt_staging2.BUDNI_PTO_Perf_Report_block -set ods_record=0 where rank in (1,2,3); - - -update mmt_staging2.BUDNI_PTO_Perf_Report_block set ods_record=0 where column3 is null -and column2 in( -select column2 from mmt_staging2.BUDNI_PTO_Perf_Report_block group by column2 having count(*)>1 -); - - - - update mmt_staging2.BUDNI_PTO_Perf_Report_block set make=__make,model=__model; - execute 'update mmt_staging2.BUDNI_PTO_Perf_Report_block set -client_id='||p_client_id||', -function_id='||p_function_id||', - file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''', - file_syspk='||p_file_syspk||''; - - - /* block */ - insert into mmt_staging2.BUDNI_PTO_MMTKeyword1_block -( column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12,rank) -select column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12,rank -from mmt_staging2.stg_process_table_budni_pto -where rank_tag='BUDNI_PTO_MMTKeyword1'; - - -update mmt_staging2.BUDNI_PTO_MMTKeyword1_block set ods_record=0 where rank in (1,2); - -update mmt_staging2.BUDNI_PTO_MMTKeyword1_block set make=__make,model=__model; -execute 'update mmt_staging2.BUDNI_PTO_MMTKeyword1_block set -client_id='||p_client_id||', -function_id='||p_function_id||', - file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''', - file_syspk='||p_file_syspk||''; - - /* block */ - -insert into mmt_staging2.BUDNI_PTO_MMTKeyword2_block -( column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12,rank) -select column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12,rank -from mmt_staging2.stg_process_table_budni_pto -where rank_tag='BUDNI_PTO_MMTKeyword2'; - - -update mmt_staging2.BUDNI_PTO_MMTKeyword2_block set ods_record=0 where rank in (1,2); - - - update mmt_staging2.BUDNI_PTO_MMTKeyword2_block set make=__make,model=__model; - execute 'update mmt_staging2.BUDNI_PTO_MMTKeyword2_block set -client_id='||p_client_id||', -function_id='||p_function_id||', - file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''', - file_syspk='||p_file_syspk||''; - - -/* block */ - -insert into mmt_staging2.BUDNI_PTO_Summary_Block -( column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12,rank) -select column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12,rank -from mmt_staging2.stg_process_table_budni_pto -where rank_tag='BUDNI_PTO_Summary'; - - -update mmt_staging2.BUDNI_PTO_Summary_block -set ods_record=0 where rank in (1,2); - - update mmt_staging2.BUDNI_PTO_Summary_block set make=__make, model=__model; - execute 'update mmt_staging2.BUDNI_PTO_Summary_block set - client_id='||p_client_id||', -function_id='||p_function_id||', - file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''', - file_syspk='||p_file_syspk||''; - - return __model; - -end -$$ LANGUAGE plpgsql; - -select mmt_staging2.fn_BUDNI_PTO_block(20,1,'BUDNI','BUDNI_PTO',182); - diff --git a/MMT_SQL/staging2/dry_sum_execute.sql b/MMT_SQL/staging2/dry_sum_execute.sql deleted file mode 100644 index 0f5e8d6..0000000 --- a/MMT_SQL/staging2/dry_sum_execute.sql +++ /dev/null @@ -1,397 +0,0 @@ -drop function if exists mmt_staging2.fn_FTDRY_SUM_Block ; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTDRY_SUM_Block(p_client_id int,p_function_id int, p_file_format text, -p_sheet_mnemonic text, p_file_syspk int) - RETURNS void AS $$ - begin - -SET search_path TO mmt_staging2; - -delete from mmt_staging2.ftdry_sum_trac_h1_block; -delete from mmt_staging2.ftdry_sum_implement_block; -delete from mmt_staging2.ftdry_sum_test_condition_1_block; -delete from mmt_staging2.ftdry_sum_test_condition_2_block; -delete from mmt_staging2.ftdry_sum_comments_by_block; -delete from mmt_staging2.stg_specific_table_ftdry_sum; -delete from mmt_staging2.stg_process_table_ftdry_sum; - -execute 'update mmt_ods.mmt_config a -set row_number_start=null, -row_previous_number=null, -row_read_end=null, -run_time=null -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - - -execute 'insert into mmt_staging2.stg_specific_table_ftdry_sum -select * from mmt_staging1.mmt_staging_generic_table a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.file_syspk='||p_file_syspk||''; - - -update mmt_staging2.stg_specific_table_ftdry_sum set column2 = TRIM (TRAILING FROM column2 ); -update mmt_staging2.stg_specific_table_ftdry_sum set column2 = TRIM (LEADING FROM column2 ); - - -update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified); -update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ; -update mmt_ods.mmt_config set F1_source=F1_modified ; -update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source); -update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source) ; - -execute 'update mmt_ods.mmt_config a set f1_source = replace(f1_source,''_1'','''') -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a -set row_number_start=(select min(b.row_number) -from mmt_staging2.stg_specific_table_ftdry_sum b -where F1_source=column2 -and b.is_rownumber_fetched is null) -where a.row_number_start is null and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_staging2.stg_specific_table_ftdry_sum a -set is_rownumber_fetched=1 -from mmt_ods.mmt_config b -where F1_source=column2 -and b.row_number_start=a.row_number -and is_rownumber_fetched is null and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a set f1_source = replace(f1_source,''_2'','''') - where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a -set row_number_start=(select min(b.row_number) -from mmt_staging2.stg_specific_table_ftdry_sum b -where F1_source=column2 -and b.is_rownumber_fetched is null) -where a.row_number_start is null and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_staging2.stg_specific_table_ftdry_sum a -set is_rownumber_fetched=1 -from mmt_ods.mmt_config b -where F1_source=column2 -and b.row_number_start=a.row_number -and is_rownumber_fetched is null and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1 -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -execute 'update mmt_ods.mmt_config a -set row_read_end= (select b.row_number_start -from mmt_ods.mmt_config b -where b.syspk=a.syspk+1 ) -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a - set row_read_end = null where f1_modified =''Test Manager Comments_2'' and -a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a -set run_time=current_timestamp where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'insert into mmt_staging2.stg_process_table_ftdry_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftdry_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Tractor Model'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - - -execute 'insert into mmt_staging2.stg_process_table_ftdry_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftdry_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Make of Implement'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_ftdry_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftdry_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Condition_1:'' - and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_ftdry_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftdry_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Engineer Comments_1'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_ftdry_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftdry_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Manager Comments_1'' - and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - -execute 'insert into mmt_staging2.stg_process_table_ftdry_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftdry_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Condition_2:'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_ftdry_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftdry_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Engineer Comments_2'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_ftdry_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftdry_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Manager Comments_2'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - -insert into mmt_staging2.FTDRY_SUM_Trac_H1_Block -( -Tractor_Model, -Tractor_Make, -Tractor_Engine_HP, -Rated_RPM, -Transmission_Type, -Wheel_Drive_Type, -FIP_Type, -Steering_Type, -Tractor_Weight_kg_Front, -Tractor_Weight_kg_Rear, -Tractor_Weight_kg_Total -) -select column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12 -from mmt_staging2.stg_process_table_ftdry_sum -where rank_tag='FTDRY_SUM_Trac_H1' and rank <> 1; - -/*delete from mmt_staging2.FTWET_TRS_SPEC_Block where dummy_f is null ;*/ -execute 'update mmt_staging2.FTDRY_SUM_Trac_H1_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -insert into mmt_staging2.FTDRY_SUM_Implement_Block -( -Make_of_Implement, -Implement_Type, -Implement_Size, -Hitch_Category, -Implement_Weight, -Soil_Type, -Moisture_Content , -Bulk_Density_g_cc , -Soil_Cone_index, -Field_Condition , -Season -) -select column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12 -from mmt_staging2.stg_process_table_ftdry_sum -where rank_tag='FTDRY_SUM_Implement' and rank not in(1,3); - -/*delete from mmt_staging2.FTDRY_SUM_Implement_Block where dummy_f is null */ -execute 'update mmt_staging2.FTDRY_SUM_Implement_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - -insert into mmt_staging2.FTDRY_SUM_Test_Condition_1_Block -( -dummy_f, -Test_Condition, -Test_Date, -Tractor_Model, -Engine_RPM_set, -PTO_RPM_set, -Gear_Used, -Nominal_Speed_KMPH, -Engine_RPM_Drop_on_straight, -Engine_RPM_Drop_on_turn, -Depth_of_cut_cm, -No_load_speed_kmph, -On_load_speed_kmph, -wheel_slippage_, -Fuel_consumption_lit_hr, -Area_covered_acr_hr, -Fuel_consumption_lit_Acr, -M_M_Performance_in_compared_to_respective_competitor_tractors, -Fuel_consumption_lit_hr_2, -Area_covered_acr_hr_2, -Fuel_consumption_lit_Acr_2, -Trail_Observations, -Engine_Smoke_on_Load, -Engine_acceleration_smoke, -Draft_Response, -Tractor_Steer_ability, -Tractor_braking_performance, -Front_Visibility, -Implement_Accessibility, -Front_Wheel_dragging_at_turning, -Front_end_lifting_during_operation, -RPM_Recovery_Time, -Engine_Vibration, -Engine_Sound, -Implement_Lifting_Lowering_response, -Pulverization_Quality, -Pulverization_Index -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3,column4,column5,column6,column7,column8,column9,column10,column11,column12}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text, -column4::text,column5::text,column6::text,column7::text,column8::text, -column9::text,column10::text,column11::text,column12::text]) AS val - FROM mmt_staging2.stg_process_table_ftdry_sum where rank_tag=''FTDRY_SUM_Test_Condition_1'' - ORDER BY generate_series(1,15),2' - ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text,a_10 text, - a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,a_18 text,a_19 text,a_20 text - ,a_21 text,a_22 text,a_23 text,a_24 text,a_25 text,a_26 text,a_27 text,a_28 text,a_29 text,a_30 text, -a_31 text,a_32 text,a_33 text,a_34 text,a_35 text,a_36 text); - -delete from mmt_staging2.FTDRY_SUM_Test_Condition_1_Block where dummy_f is null ; -execute 'update mmt_staging2.FTDRY_SUM_Test_Condition_1_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - -insert into mmt_staging2.FTDRY_SUM_Test_Condition_2_Block -( -dummy_f, -Test_Condition, -Test_Date, -Tractor_Model, -Engine_RPM_set, -PTO_RPM_set, -Gear_Used, -Nominal_Speed_KMPH, -Engine_RPM_Drop_on_straight, -Engine_RPM_Drop_on_turn, -Depth_of_cut_cm, -No_load_speed_kmph, -On_load_speed_kmph, -wheel_slippage_, -Fuel_consumption_lit_hr, -Area_covered_acr_hr, -Fuel_consumption_lit_Acr, -M_M_Performance_in_compared_to_respective_competitor_tractors, -Fuel_consumption_lit_hr_2, -Area_covered_acr_hr_2, -Fuel_consumption_lit_Acr_2, -Trail_Observations, -Engine_Smoke_on_Load, -Engine_acceleration_smoke, -Draft_Response, -Tractor_Steer_ability, -Tractor_braking_performance, -Front_Visibility, -Implement_Accessibility, -Front_Wheel_dragging_at_turning, -Front_end_lifting_during_operation, -RPM_Recovery_Time, -Engine_Vibration, -Engine_Sound, -Implement_Lifting_Lowering_response, -Pulverization_Quality, -Pulverization_Index -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3,column4,column5,column6,column7,column8,column9,column10,column11,column12}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text,column4::text,column5::text,column6::text,column7::text,column8::text,column9::text,column10::text,column11::text,column12::text]) AS val - FROM mmt_staging2.stg_process_table_ftdry_sum where rank_tag=''FTDRY_SUM_Test_Condition_2'' - ORDER BY generate_series(1,15),2' - ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text, - a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,a_18 text,a_19 text,a_20 text,a_21 text, - a_22 text,a_23 text,a_24 text,a_25 text,a_26 text,a_27 text,a_28 text,a_29 text,a_30 text,a_31 text, - a_32 text,a_33 text,a_34 text,a_35 text,a_36 text); - -delete from mmt_staging2.FTDRY_SUM_Test_Condition_2_Block where dummy_f is null ; -execute 'update mmt_staging2.FTDRY_SUM_Test_Condition_2_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - -insert into mmt_staging2.FTDRY_SUM_Comments_By_Block (dummy_f) values ('dummy'); - -execute 'update mmt_staging2.FTDRY_SUM_Comments_By_Block set Test_Engineer_Comments_1= -(select column3 from mmt_staging2.stg_process_table_ftdry_sum a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.rank_tag=''FTDRY_SUM_Engineer_Comments_1'' -and a.rank=1 ) where dummy_f=''dummy'''; - -execute 'update mmt_staging2.FTDRY_SUM_Comments_By_Block set test_engineer_comments_2= -(select column3 from mmt_staging2.stg_process_table_ftdry_sum a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.rank_tag=''FTDRY_SUM_Engineer_Comments_2'' -and a.rank=1 ) where dummy_f=''dummy'''; - -execute 'update mmt_staging2.FTDRY_SUM_Comments_By_Block set test_manager_comments_1= -(select column3 from mmt_staging2.stg_process_table_ftdry_sum a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.rank_tag=''FTDRY_SUM_Manager_Comments_1'' -and a.rank=1 ) where dummy_f=''dummy'''; - -execute 'update mmt_staging2.FTDRY_SUM_Comments_By_Block set test_manager_comments_2= -(select column3 from mmt_staging2.stg_process_table_ftdry_sum a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.rank_tag=''FTDRY_SUM_Manager_Comments_2'' -and a.rank=1 ) where dummy_f=''dummy'''; - - -delete from mmt_staging2.FTDRY_SUM_Comments_By_Block where dummy_f is null ; -execute 'update mmt_staging2.FTDRY_SUM_Comments_By_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - -end -$$ LANGUAGE plpgsql; - -select mmt_staging2.fn_FTDRY_SUM_Block (20,1,'FTDRY','FTDRY_SUM',179); - - - - - - - diff --git a/MMT_SQL/staging2/dry_trs_execute.sql b/MMT_SQL/staging2/dry_trs_execute.sql deleted file mode 100644 index 1ca3384..0000000 --- a/MMT_SQL/staging2/dry_trs_execute.sql +++ /dev/null @@ -1,345 +0,0 @@ -/*FTDRY_starts*/ -drop function if exists mmt_staging2.fn_FTDRY_TRS_Block ; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTDRY_TRS_Block(p_client_id int,p_function_id int, p_file_format text, -p_sheet_mnemonic text, p_file_syspk int) - RETURNS void AS $$ - begin - -SET search_path TO mmt_staging2; - -delete from mmt_staging2.FTDRY_TRS_H1_INT; -delete from mmt_staging2.ftdry_trs_h1_block ; -delete from mmt_staging2.ftdry_trs_implement_block ; -delete from mmt_staging2.ftdry_trs_spec_block; -delete from mmt_staging2.ftdry_trs_engine_rpm_block; -delete from mmt_staging2.stg_specific_table_ftdry_trs; -delete from mmt_staging2.stg_process_table_ftdry_trs; - - -execute 'update mmt_ods.mmt_config a -set row_number_start=null, -row_previous_number=null, -row_read_end=null, -run_time=null -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - - -execute 'insert into mmt_staging2.stg_specific_table_ftdry_trs -select * from mmt_staging1.mmt_staging_generic_table a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.file_syspk='||p_file_syspk||''; - -update mmt_staging2.stg_specific_table_ftdry_trs set column2 = TRIM (TRAILING FROM column2 ); -update mmt_staging2.stg_specific_table_ftdry_trs set column2 = TRIM (LEADING FROM column2 ); - - -update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified); -update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified); -update mmt_ods.mmt_config set F1_source=F1_modified; -update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source) ; -update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source); - -/* updating mmt_config*/ - -execute 'update mmt_ods.mmt_config a -set row_number_start=(select min(b.row_number) -from mmt_staging2.stg_specific_table_ftdry_trs b -where trim(upper(F1_source))= trim(upper(column2)) -and b.is_rownumber_fetched is null) -where a.row_number_start is null and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_staging2.stg_specific_table_ftdry_trs a -set is_rownumber_fetched=1 -from mmt_ods.mmt_config b -where trim(upper(F1_source))= trim(upper(column2)) -and b.row_number_start=a.row_number -and is_rownumber_fetched is null and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1 -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -execute 'update mmt_ods.mmt_config a -set row_read_end= (select b.row_number_start -from mmt_ods.mmt_config b -where b.syspk=a.syspk+1 ) -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a set row_read_end = null -where f1_modified =''Implement Details'' and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a -set run_time=current_timestamp -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -/*rank tags*/ - -execute 'insert into mmt_staging2.stg_process_table_ftdry_trs -select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftdry_trs a -join mmt_ods.mmt_config b -on a.row_number >row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Tractor Specifications Sheet'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - - -execute 'insert into mmt_staging2.stg_process_table_ftdry_trs -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftdry_trs a -join mmt_ods.mmt_config b -on a.row_number >row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Tractor Specifications'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_ftdry_trs -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftdry_trs a -join mmt_ods.mmt_config b -on a.row_number >row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Engine RPM Data:'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - -execute 'insert into mmt_staging2.stg_process_table_ftdry_trs -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftdry_trs a -join mmt_ods.mmt_config b -on a.row_number >row_number_start -and a.column2 <> '''' -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Implement Details'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - - - -/*insert data into h1_int */ - - -insert into mmt_staging2.FTDRY_TRS_H1_INT(column2,column3,column4,column5,column6,column7) -select column2,column3,column4,column5,column6,column7 from mmt_staging2.stg_process_table_ftdry_trs a where rank_tag='FTDRY_TRS_H1'; - -insert into mmt_staging2.FTDRY_TRS_H1_INT(column2) values ('Date of Test'); - -insert into mmt_staging2.FTDRY_TRS_H1_INT(column2) values ('Report Date'); - -insert into mmt_staging2.FTDRY_TRS_H1_INT(column2) values ('Season'); - -insert into mmt_staging2.FTDRY_TRS_H1_INT (column2) values ('Type of Soil'); - -insert into mmt_staging2.FTDRY_TRS_H1_INT (column2) values ('Soil Cone Index (kPa)'); - -insert into mmt_staging2.FTDRY_TRS_H1_INT (column2) values ('Field Condition'); - - -update mmt_staging2.FTDRY_TRS_H1_INT a -set column3=(select column5 from mmt_staging2.FTDRY_TRS_H1_INT b -where trim(a.column2)=trim(b.column4) -and b.column4='Date of Test') -where a.column2='Date of Test'; - - -update mmt_staging2.FTDRY_TRS_H1_INT a -set column3=(select column7 from mmt_staging2.FTDRY_TRS_H1_INT b -where trim(a.column2)=trim(b.column6) -and b.column6='Report Date') -where a.column2='Report Date'; - -update mmt_staging2.FTDRY_TRS_H1_INT a -set column3=(select column6 from mmt_staging2.FTDRY_TRS_H1_INT b -where trim(a.column2)=trim(b.column5) -and b.column5='Season') -where a.column2='Season'; - -update mmt_staging2.FTDRY_TRS_H1_INT a -set column3=(select column6 from mmt_staging2.FTDRY_TRS_H1_INT b -where trim(a.column2)=trim(b.column5) -and b.column5='Type of Soil') -where a.column2='Type of Soil'; - - -update mmt_staging2.FTDRY_TRS_H1_INT a -set column3=(select column6 from mmt_staging2.FTDRY_TRS_H1_INT b -where trim(a.column2)=trim(b.column5) -and b.column5='Soil Cone Index (kPa)') -where a.column2='Soil Cone Index (kPa)'; - - -update mmt_staging2.FTDRY_TRS_H1_INT a -set column3=(select column6 from mmt_staging2.FTDRY_TRS_H1_INT b -where trim(a.column2)=trim(b.column5) -and b.column5='Field Condition') -where a.column2='Field Condition'; - - -/*inserting data into block statements*/ - -insert into mmt_staging2.FTDRY_TRS_H1_Block -( -dummy_f, -Report_Reference_No, -Objective_Of_Test, -Background_of_Test, -Job_Order_No, -Test_Location, -Soil_Moisture_Content_, -Soil_Bulk_Density_g_cc, -Test_Engineer, -Test_Operator, -Date_of_Test, -Report_Date, -Season, -Type_of_Soil, -Soil_Cone_Index_kPa, -Field_Condition -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text]) AS val - FROM mmt_staging2.FTDRY_TRS_H1_INT - ORDER BY generate_series(1,15),2' - ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text,a_10 text, - a_11 text,a_12 text,a_13 text,a_14 text,a_15 text); - -delete from mmt_staging2.FTDRY_TRS_H1_Block where dummy_f is null ; -execute 'update mmt_staging2.FTDRY_TRS_H1_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - -insert into mmt_staging2.FTDRY_TRS_SPEC_Block -( -dummy_f, -Tractor_Model, -Tractor_Make, -Tractor_Sr_No, -Tractor_Engine_HP, -FIP_Type, -hour_Meter_Reading, -Steering_Type, -Transmission_Type, -Wheel_Drive_Type_WD, -EGR_Yes_No, -Brake_Type, -PTO_Type, -Standard_PTO_Speed_RPM, -EPTO_Speed_RPM, -Front_Tyre_Make, -Front_Tyre_Size, -Front_Tyre_Pressure_psi, -Rear_Tyre_Make, -Rear_Tyre_Size, -Rear_Tyre_Pressure_psi , -Tractor_Weight_kg_Front , -Tractor_Weight_kg_Rear , -Tractor_Weight_kg_Total, -Ballasted_Tractor_Accessories, -Mechanical_Ballast_Rear, -Mechanical_Ballast_Rear_in_KG , -Water_Ballast_Rear, -Mechanical_Ballast_Front, -Mechanical_Ballast_Front_in_Kg, -Total_Ballast_Weight -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3,column4,column5,column6,column7}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text,column4::text,column5::text,column6::text,column7::text]) AS val - FROM mmt_staging2.stg_process_table_ftdry_trs where rank_tag=''FTDRY_TRS_SPEC'' - ORDER BY generate_series(1,15),2' - ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text, - a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,a_18 text,a_19 text,a_20 text,a_21 text, - a_22 text,a_23 text,a_24 text,a_25 text,a_26 text,a_27 text,a_28 text,a_29 text,a_30 text); - - -delete from mmt_staging2.FTDRY_TRS_SPEC_Block where dummy_f is null ; -execute 'update mmt_staging2.FTDRY_TRS_SPEC_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - -insert into mmt_staging2.FTDRY_TRS_Engine_RPM_Block -( -dummy_f, -tractor_model, -tractor_make, -Low_Idle, -High_Idle, -Rated_RPM, -Engine_to_PTO_Ratio_540_PTO, -Engine_to_PTO_Ratio_540E_PTO -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3,column4,column5,column6,column7}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text,column4::text,column5::text,column6::text,column7::text]) AS val - FROM mmt_staging2.stg_process_table_ftdry_trs where rank_tag=''FTDRY_TRS_Engine_RPM'' - or (rank_tag=''FTDRY_TRS_SPEC'' and rank in (1,2)) - ORDER BY generate_series(1,15),2' - ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text); - - -delete from mmt_staging2.FTDRY_TRS_Engine_RPM_Block where dummy_f is null ; -execute 'update mmt_staging2.FTDRY_TRS_Engine_RPM_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - - - -insert into mmt_staging2.FTDRY_TRS_Implement_Block -( -dummy_f, -Name_of_Implement, -Type_of_Implement, -Make_of_Implement, -No_of_bottoms_Tyne_Disc_Blade, -Cutting_Width_m, -Implement_Weight_Kg, -Hitch_Category, -Span_cm_For_Mounted_Implement, -Mast_Height_cm_For_Mounted_Implement, -FDPD_TDC_Mar15_008 -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3,column4,column5,column6}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text,column4::text,column5::text,column6::text]) AS val - FROM mmt_staging2.stg_process_table_ftdry_trs where rank_tag=''FTDRY_TRS_Implement'' - ORDER BY generate_series(1,15),2' - ) t ( col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text - ,a_10 text); - - -delete from mmt_staging2.FTDRY_TRS_Implement_Block where dummy_f is null ; -execute 'update mmt_staging2.FTDRY_TRS_Implement_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -end -$$ LANGUAGE plpgsql; - - -select mmt_staging2.fn_FTDRY_TRS_Block(20,1,'FTDRY','FTDRY_TRS',179); diff --git a/MMT_SQL/staging2/hlg_sum_execute.sql b/MMT_SQL/staging2/hlg_sum_execute.sql deleted file mode 100644 index a5a5d0f..0000000 --- a/MMT_SQL/staging2/hlg_sum_execute.sql +++ /dev/null @@ -1,403 +0,0 @@ -drop function if exists mmt_staging2.fn_FTHLG_SUM_Block ; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTHLG_SUM_Block(p_client_id int,p_function_id int, p_file_format text, -p_sheet_mnemonic text, p_file_syspk int) - RETURNS void AS $$ - begin -SET search_path TO mmt_staging2; -delete from mmt_staging2.FTHLG_SUM_Trac_H1_Block; -delete from mmt_staging2.FTHLG_SUM_Trail_Type_Block; -delete from mmt_staging2.FTHLG_SUM_Test_Condition_1_Block; -delete from mmt_staging2.FTHLG_SUM_Test_Condition_2_Block; -delete from mmt_staging2.FTHLG_SUM_Comments_By_Block; -delete from mmt_staging2.stg_specific_table_fthlg_sum; -delete from mmt_staging2.stg_process_table_fthlg_sum; - -execute 'update mmt_ods.mmt_config a -set row_number_start=null, -row_previous_number=null, -row_read_end=null, -run_time=null -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'insert into mmt_staging2.stg_specific_table_fthlg_sum -select * from mmt_staging1.mmt_staging_generic_table a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.file_syspk='||p_file_syspk||''; - -update mmt_staging2.stg_specific_table_fthlg_sum set column2 = TRIM (TRAILING FROM column2 ); -update mmt_staging2.stg_specific_table_fthlg_sum set column2 = TRIM (LEADING FROM column2 ); - - -update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified); -update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ; -update mmt_ods.mmt_config set F1_source=F1_modified ; -update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source) ; -update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source) ; - -execute 'update mmt_ods.mmt_config a set f1_source = replace(f1_source,''_1'','''') -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a -set row_number_start=(select min(b.row_number) -from mmt_staging2.stg_specific_table_fthlg_sum b -where F1_source=column2 -and b.is_rownumber_fetched is null) -where a.row_number_start is null - and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_staging2.stg_specific_table_fthlg_sum a -set is_rownumber_fetched=1 -from mmt_ods.mmt_config b -where F1_source=column2 -and b.row_number_start=a.row_number -and is_rownumber_fetched is null -and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a set f1_source = replace(f1_source,''_2'','''') - where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a -set row_number_start=(select min(b.row_number) -from mmt_staging2.stg_specific_table_fthlg_sum b -where F1_source=column2 -and b.is_rownumber_fetched is null) -where a.row_number_start is null -and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_staging2.stg_specific_table_fthlg_sum a -set is_rownumber_fetched=1 -from mmt_ods.mmt_config b -where F1_source=column2 -and b.row_number_start=a.row_number -and is_rownumber_fetched is null and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1 -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -execute 'update mmt_ods.mmt_config a -set row_read_end= (select b.row_number_start -from mmt_ods.mmt_config b -where b.syspk=a.syspk+1 ) -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a set row_read_end = null where f1_modified =''Test Manager Comments_2'' and - a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a -set run_time=current_timestamp -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - - -execute 'insert into mmt_staging2.stg_process_table_fthlg_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_fthlg_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Objective Of Test'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - - -execute 'insert into mmt_staging2.stg_process_table_fthlg_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_fthlg_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Trailer Type'' - and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_fthlg_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_fthlg_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Condition_1:'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_fthlg_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_fthlg_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Engineer Comments_1'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_fthlg_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_fthlg_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Manager Comments_1'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - -execute 'insert into mmt_staging2.stg_process_table_fthlg_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_fthlg_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Condition_2:'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_fthlg_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_fthlg_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Engineer Comments_2'' -and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_fthlg_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_fthlg_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Manager Comments_2'' - and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - - - -insert into mmt_staging2.FTHLG_SUM_Trac_H1_Block -( -tractor_model, -tractor_make , -tractor_engine_hp, -rated_rpm, -transmission_type, -wheel_drive_type, -fip_type, -steering_type, -tractor_weight_kg_front, -tractor_weight_kg_rear, -tractor_weight_kg_total -) -select column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12 -from mmt_staging2.stg_process_table_fthlg_sum -where rank_tag='FTHLG_SUM_Trac_H1' and rank <> 1; - - ---delete from mmt_staging2.FTHLG_SUM_Trac_H1_Block where dummy_f is null ; -execute 'update mmt_staging2.FTHLG_SUM_Trac_H1_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - - - - -insert into mmt_staging2.FTHLG_SUM_Trail_Type_Block -( -Trailer_Type, -Tire_size_and_inflation_pressure_psi, -No_Of_Axle, -No_Of_Wheels, -Trailer_Gross_Weight_Kg, -Tractor_Rear_Wheel_Center_to_Hitch_Point_Center_Distance_mm, -Tractor_Hitch_Height_from_Ground_mm, -Trailer_hitch_Height_above_ground_level_mm, -Gradient_Slope_1_Degree, -Gradient_Slope_2_degree, -Tractor_Hitch_Type -) -select column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12 -from mmt_staging2.stg_process_table_fthlg_sum -where rank_tag='FTHLG_SUM_Trail_Type' and rank <> 1; - - ---delete from mmt_staging2.FTHLG_SUM_Trail_Type_Block where dummy_f is null ; -execute 'update mmt_staging2.FTHLG_SUM_Trail_Type_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - - - -insert into mmt_staging2.FTHLG_SUM_Test_Condition_1_Block -( -dummy_f, -Test_Condition, -Test_Date, -Tractor_Model, -Fuel_consumption_Ltr_hr, -Mileage_Km_Ltr, -Average_speed_of_travel_kmph, -Total_distance_travelled_km, -Gear_used_on_Straight_Road, -Straight_road_RPM_Drop, -Gear_used_on_Up_Slope_1, -Up_Slope_RPM_Drop_1, -Gear_used_on_Up_Slope_2, -Up_Slope_RPM_Drop_2, -Gear_used_on_Down_Slope, -Down_Slope_RPM_Shoot_up, -M_M_Performance_compared_to_respective_competitor_tractors_is_better_and_is_poor_than_competitor, -Fuel_consumption_lit_hr_2, -Mileage_Km_Ltr_2, -M_M_Performance_in_compared_to_respective_competitor_tractors, -Fuel_consumption_lit_hr_3, -Mileage_Km_Ltr_3, -Engine_Smoke_on_Load, -Engine_acceleration_smoke, -Range_Gear_Shifting, -Speed_Gear_Shifting, -Tractor_Steer_ability, -Tractor_braking_performance, -Front_Visibility, -Implement_Accessibility, -Front_end_lifting_during_operation, -RPM_Recovery_Time, -Engine_Vibration, -Engine_Sound -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3,column4,column5,column6,column7,column8,column9,column10,column11,column12}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text, -column4::text,column5::text,column6::text,column7::text,column8::text, -column9::text,column10::text,column11::text,column12::text]) AS val - FROM mmt_staging2.stg_process_table_fthlg_sum where rank_tag=''FTHLG_SUM_Test_Condition_1'' - ORDER BY generate_series(1,15),2' - ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text,a_10 text, - a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,a_18 text,a_19 text,a_20 text - ,a_21 text,a_22 text,a_23 text,a_24 text,a_25 text,a_26 text,a_27 text,a_28 text,a_29 text,a_30 text, -a_31 text,a_32 text,a_33 text); - - -delete from mmt_staging2.FTHLG_SUM_Test_Condition_1_Block where dummy_f is null ; -execute 'update mmt_staging2.FTHLG_SUM_Test_Condition_1_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - - - -insert into mmt_staging2.FTHLG_SUM_Test_Condition_2_Block -( -dummy_f, -Test_Condition, -Test_Date, -Tractor_Model, -Fuel_consumption_Ltr_hr, -Mileage_Km_Ltr, -Average_speed_of_travel_kmph, -Total_distance_travelled_km, -Gear_used_on_Straight_Road, -Straight_road_RPM_Drop, -Gear_used_on_Up_Slope_1, -Up_Slope_RPM_Drop_1, -Gear_used_on_Up_Slope_2, -Up_Slope_RPM_Drop_2, -Gear_used_on_Down_Slope, -Down_Slope_RPM_Shoot_up, -M_M_Performance_compared_to_respective_competitor_tractors_is_better_and_is_poor_than_competitor, -Fuel_consumption_lit_hr_2, -Mileage_Km_Ltr_2, -M_M_Performance_in_compared_to_respective_competitor_tractors, -Fuel_consumption_lit_hr_3, -Mileage_Km_Ltr_3, -Engine_Smoke_on_Load, -Engine_acceleration_smoke, -Range_Gear_Shifting, -Speed_Gear_Shifting, -Tractor_Steer_ability, -Tractor_braking_performance, -Front_Visibility, -Implement_Accessibility, -Front_end_lifting_during_operation, -RPM_Recovery_Time, -Engine_Vibration, -Engine_Sound -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3,column4,column5,column6,column7,column8,column9,column10,column11,column12}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text,column4::text,column5::text,column6::text,column7::text,column8::text,column9::text,column10::text,column11::text,column12::text]) AS val - FROM mmt_staging2.stg_process_table_fthlg_sum where rank_tag=''FTHLG_SUM_Test_Condition_2'' - ORDER BY generate_series(1,15),2' - ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text, - a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,a_18 text,a_19 text,a_20 text,a_21 text, - a_22 text,a_23 text,a_24 text,a_25 text,a_26 text,a_27 text,a_28 text,a_29 text,a_30 text,a_31 text - ,a_32 text,a_33 text); - - -delete from mmt_staging2.FTHLG_SUM_Test_Condition_2_Block where dummy_f is null ; -execute 'update mmt_staging2.FTHLG_SUM_Test_Condition_2_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - - - -insert into mmt_staging2.FTHLG_SUM_Comments_By_Block (dummy_f) values -('dummy'); - -execute 'update mmt_staging2.FTHLG_SUM_Comments_By_Block set test_engineer_comments_1= -(select column3 from mmt_staging2.stg_process_table_fthlg_sum a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.rank_tag=''FTHLG_SUM_Engineer_Comments_1'' -and rank=1 ) where dummy_f=''dummy''' ; - -execute 'update mmt_staging2.FTHLG_SUM_Comments_By_Block set test_engineer_comments_2= -(select column3 from mmt_staging2.stg_process_table_fthlg_sum a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.rank_tag=''FTHLG_SUM_Engineer_Comments_2'' -and rank=1 ) where dummy_f=''dummy'''; - -execute 'update mmt_staging2.FTHLG_SUM_Comments_By_Block set test_manager_comments_1= -(select column3 from mmt_staging2.stg_process_table_fthlg_sum a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.rank_tag=''FTHLG_SUM_Manager_Comments_1'' -and rank=1 ) where dummy_f=''dummy'''; - -execute 'update mmt_staging2.FTHLG_SUM_Comments_By_Block set test_manager_comments_2= -(select column3 from mmt_staging2.stg_process_table_fthlg_sum a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.rank_tag=''FTHLG_SUM_Manager_Comments_2'' -and rank=1 ) where dummy_f=''dummy'''; - - - -delete from mmt_staging2.FTHLG_SUM_Comments_By_Block where dummy_f is null ; - -execute 'update mmt_staging2.FTHLG_SUM_Comments_By_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - -end -$$ LANGUAGE plpgsql; - -select mmt_staging2.fn_FTHLG_SUM_Block(20,1,'FTHLG','FTHLG_SUM',180) - - diff --git a/MMT_SQL/staging2/hlg_trs_execute.sql b/MMT_SQL/staging2/hlg_trs_execute.sql deleted file mode 100644 index e7b8f03..0000000 --- a/MMT_SQL/staging2/hlg_trs_execute.sql +++ /dev/null @@ -1,331 +0,0 @@ -drop function if exists mmt_staging2.fn_fthlg_trs_block; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_fthlg_trs_block(p_client_id int,p_function_id int, p_file_format text, -p_sheet_mnemonic text, p_file_syspk int) - RETURNS void AS $$ - begin - - -delete from mmt_staging2.FTHLG_TRS_H1_INT; -delete from mmt_staging2.FTHLG_TRS_H1_Block; -delete from mmt_staging2.FTHLG_TRS_SPEC_Block; -delete from mmt_staging2.FTHLG_TRS_Engine_RPM_Block; -delete from mmt_staging2.FTHLG_TRS_Trailer_Block; -delete from mmt_staging2.stg_specific_table_fthlg_trs; -delete from mmt_staging2.stg_process_table_fthlg_trs; - -execute 'update mmt_ods.mmt_config a -set row_number_start=null, -row_previous_number=null, -row_read_end=null, -run_time=null -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'insert into mmt_staging2.stg_specific_table_fthlg_trs -select * from mmt_staging1.mmt_staging_generic_table a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.file_syspk='||p_file_syspk||''; - -update mmt_staging2.stg_specific_table_fthlg_trs set column2 = TRIM (TRAILING FROM column2 ); -update mmt_staging2.stg_specific_table_fthlg_trs set column2 = TRIM (LEADING FROM column2 ); - - - -update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified); -update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified); -update mmt_ods.mmt_config set F1_source=F1_modified; -update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source); -update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source); - -execute 'update mmt_ods.mmt_config a -set row_number_start=(select min(b.row_number) -from mmt_staging2.stg_specific_table_fthlg_trs b -where F1_source=column2 -and b.is_rownumber_fetched is null) -where a.row_number_start is null and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -execute 'update mmt_staging2.stg_specific_table_fthlg_trs a -set is_rownumber_fetched=1 -from mmt_ods.mmt_config b -where F1_source=column2 -and b.row_number_start=a.row_number -and is_rownumber_fetched is null and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1 -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - - -execute 'update mmt_ods.mmt_config a -set row_read_end= (select b.row_number_start -from mmt_ods.mmt_config b -where b.syspk=a.syspk+1 ) -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -execute 'update mmt_ods.mmt_config a set row_read_end = null where f1_modified =''Trailer Details'' and -a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -execute 'update mmt_ods.mmt_config a -set run_time=current_timestamp where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -execute 'insert into mmt_staging2.stg_process_table_fthlg_trs -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_fthlg_trs a -join mmt_ods.mmt_config b -on a.row_number >row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Tractor specifications sheet'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - - -execute 'insert into mmt_staging2.stg_process_table_fthlg_trs -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_fthlg_trs a -join mmt_ods.mmt_config b -on a.row_number >row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Tractor Specifications'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_fthlg_trs -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_fthlg_trs a -join mmt_ods.mmt_config b -on a.row_number >row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Engine RPM Data:'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_fthlg_trs -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_fthlg_trs a -join mmt_ods.mmt_config b -on a.row_number >row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Trailer Details'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -delete from mmt_staging2.stg_process_table_fthlg_trs where row_number between 88 and 98; - -insert into mmt_staging2.FTHLG_TRS_H1_INT(column2,column3,column4,column5,column6,column7) -select column2,column3,column4,column5,column6,column7 from mmt_staging2.stg_process_table_fthlg_trs a -where rank_tag='FTHLG_TRS_H1'; - - -insert into mmt_staging2.FTHLG_TRS_H1_INT(column2) values ('Date of Test'); - -insert into mmt_staging2.FTHLG_TRS_H1_INT(column2) values ('Report Date'); - -insert into mmt_staging2.FTHLG_TRS_H1_INT(column2) values ('Type of Road'); - -insert into mmt_staging2.FTHLG_TRS_H1_INT (column2) values ('Tractor Hitch Height from Ground, mm'); - -insert into mmt_staging2.FTHLG_TRS_H1_INT (column2) values ('Tractor Rear Wheel Center to Hitch Point Center Distance, mm'); - - -update mmt_staging2.FTHLG_TRS_H1_INT a -set column3=(select column5 from mmt_staging2.FTHLG_TRS_H1_INT b -where trim(a.column2)=trim(b.column4) -and b.column4='Date of Test') -where a.column2='Date of Test'; - -update mmt_staging2.FTHLG_TRS_H1_INT a -set column3=(select column7 from mmt_staging2.FTHLG_TRS_H1_INT b -where trim(a.column2)=trim(b.column6) -and b.column6='Report Date') -where a.column2='Report Date'; - -update mmt_staging2.FTHLG_TRS_H1_INT a -set column3=(select column6 from mmt_staging2.FTHLG_TRS_H1_INT b -where trim(a.column2)=trim(b.column5) -and b.column5='Type of Road') -where a.column2='Type of Road'; - -update mmt_staging2.FTHLG_TRS_H1_INT a -set column3=(select column6 from mmt_staging2.FTHLG_TRS_H1_INT b -where trim(a.column2)=trim(b.column5) -and b.column5='Tractor Hitch Height from Ground, mm') -where a.column2='Tractor Hitch Height from Ground, mm'; - - -update mmt_staging2.FTHLG_TRS_H1_INT a -set column3=(select column6 from mmt_staging2.FTHLG_TRS_H1_INT b -where trim(a.column2)=trim(b.column5) -and b.column5='Tractor Rear Wheel Center to Hitch Point Center Distance, mm') -where a.column2='Tractor Rear Wheel Center to Hitch Point Center Distance, mm'; - - -insert into mmt_staging2.FTHLG_TRS_H1_Block -( -dummy_f, -Report_Reference_No, -Objective_Of_Test, -Background_of_Test, -Job_Order_No, -Test_Location, -Gradient_Slope_1_Degree, -Gradient_Slope_2_Degree, -Tractor_Hitch_Type, -Test_Engineer, -Test_Operator, -Date_of_Test, -Report_Date, -Type_of_Road, -Tractor_Hitch_Height_from_Ground_mm, -Tractor_Rear_Wheel_Center_to_Hitch_Point_Center_Distance_mm -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text]) AS val - FROM mmt_staging2.FTHLG_TRS_H1_INT - ORDER BY generate_series(1,15),2' - ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text,a_10 text, - a_11 text,a_12 text,a_13 text,a_14 text,a_15 text); - - -delete from mmt_staging2.FTHLG_TRS_H1_Block where dummy_f is null ; -execute 'update mmt_staging2.FTHLG_TRS_H1_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - -insert into mmt_staging2.FTHLG_TRS_SPEC_Block -( -dummy_f, -Tractor_Model, -Tractor_Make, -Tractor_Sr_No, -Tractor_Engine_HP, -FIP_Type, -hour_Meter_Reading, -Steering_Type, -Transmission_Type, -Wheel_Drive_Type_WD, -EGR_Yes_No, -Brake_Type, -PTO_Type, -Standard_PTO_Speed_RPM, -EPTO_Speed_RPM, -Front_Tyre_Make, -Front_Tyre_Size, -Front_Tyre_Pressure_psi, -Rear_Tyre_Make, -Rear_Tyre_Size, -Rear_Tyre_Pressure_psi , -Tractor_Weight_kg_Front , -Tractor_Weight_kg_Rear , -Tractor_Weight_kg_Total, -Ballasted_Tractor_Accessories, -Mechanical_Ballast_Rear, -Mechanical_Ballast_Rear_in_KG , -Water_Ballast_Rear_75, -Mechanical_Ballast_Front_in_Kg, -Mechanical_Ballast_Front, -Total_Ballast_Weight -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3,column4,column5,column6,column7}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text,column4::text,column5::text,column6::text,column7::text]) AS val - FROM mmt_staging2.stg_process_table_fthlg_trs where rank_tag=''FTHLG_TRS_SPEC'' - ORDER BY generate_series(1,15),2' - ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text, - a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,a_18 text,a_19 text,a_20 text,a_21 text, - a_22 text,a_23 text,a_24 text,a_25 text,a_26 text,a_27 text,a_28 text,a_29 text,a_30 text); - - -delete from mmt_staging2.FTHLG_TRS_SPEC_Block where dummy_f is null ; -execute 'update mmt_staging2.FTHLG_TRS_SPEC_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -insert into mmt_staging2.FTHLG_TRS_Engine_RPM_Block -( -dummy_f, -Tractor_model, -Tractor_make, -Low_Idle, -High_Idle, -Rated_RPM, -Engine_to_PTO_Ratio_540_PTO, -Engine_to_PTO_Ratio_540E_PTO -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3,column4,column5,column6,column7}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text,column4::text,column5::text,column6::text,column7::text]) AS val - FROM mmt_staging2.stg_process_table_fthlg_trs where rank_tag=''FTHLG_TRS_Engine_RPM'' - or (rank_tag=''FTHLG_TRS_SPEC'' and rank in (1,2)) - ORDER BY generate_series(1,15),2' - ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text); - - -delete from mmt_staging2.FTHLG_TRS_Engine_RPM_Block where dummy_f is null ; -execute 'update mmt_staging2.FTHLG_TRS_Engine_RPM_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - -insert into mmt_staging2.FTHLG_TRS_Trailer_Block -( -dummy_f, -Type_Of_Trailer, -No_Of_Axle, -No_Of_Wheels, -Trailer_hitch_Height_above_ground_level_mm, -Make_model_of_trailer, -Trailer_platform_length_mm, -Trailer_platform_Width_mm, -Trailer_platform_Height_mm, -Tire_size, -Inflation_pressure_psi, -Track_width_of_trailer_mm, -Horizontal_distance_of_hitch_point_from_trailer_front_face_mm, -Tractor_Rear_Wheel_Center_to_Hitch_Point_Center_Distance_mm, -Distance_from_Trailerfront_axle_distance_from_hitch_point_mm, -Distance_from_tractor_rear_wheel_center_to_tractor_rear_wheel_center_mm, -Trailer_empty_weight_Kg, -Trailer_Gross_Weight_Kg, -FDPD_TDC_Mar15_009 -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3,column4,column5,column6}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text,column4::text,column5::text,column6::text]) AS val - FROM mmt_staging2.stg_process_table_fthlg_trs where rank_tag=''FTHLG_TRS_Trailer'' - ORDER BY generate_series(1,15),2' - ) t ( col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text - ,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,a_18 text); - -delete from mmt_staging2.FTHLG_TRS_Trailer_Block where dummy_f is null ; -execute 'update mmt_staging2.FTHLG_TRS_Trailer_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - -end -$$ LANGUAGE plpgsql; - -select mmt_staging2.fn_fthlg_trs_block(20,1,'FTHLG','FTHLG_TRS',180) - - diff --git a/MMT_SQL/staging2/wet_sum_execute.sql b/MMT_SQL/staging2/wet_sum_execute.sql deleted file mode 100644 index f40081c..0000000 --- a/MMT_SQL/staging2/wet_sum_execute.sql +++ /dev/null @@ -1,289 +0,0 @@ -drop function if exists mmt_staging2.fn_FTWET_SUM_Block ; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTWET_SUM_Block(p_client_id int,p_function_id int, p_file_format text, -p_sheet_mnemonic text, p_file_syspk int) - RETURNS void AS $$ - begin - -SET search_path TO mmt_staging2; -delete from mmt_staging2.FTWET_SUM_Trac_H1_Block; -delete from mmt_staging2.FTWET_SUM_Implement_Block; -delete from mmt_staging2.FTWET_SUM_Cage_Wheel_Block; -delete from mmt_staging2.FTWET_SUM_Test_Condition_Block; -delete from mmt_staging2.FTWET_SUM_Comments_By_Block; -delete from mmt_staging2.stg_specific_table_ftwet_sum; -delete from mmt_staging2.stg_process_table_ftwet_sum; - -execute 'update mmt_ods.mmt_config a -set row_number_start=null, -row_previous_number=null, -row_read_end=null, -run_time=null -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'insert into mmt_staging2.stg_specific_table_ftwet_sum -select * from mmt_staging1.mmt_staging_generic_table a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' - and a.file_syspk='||p_file_syspk||''; - - -update mmt_staging2.stg_specific_table_ftwet_sum set column2 = TRIM (TRAILING FROM column2 ); -update mmt_staging2.stg_specific_table_ftwet_sum set column2 = TRIM (LEADING FROM column2 ); - - -update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified); -update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ; -update mmt_ods.mmt_config set F1_source=F1_modified; -update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source); -update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source); - - -execute 'update mmt_ods.mmt_config a -set row_number_start=(select min(b.row_number) -from mmt_staging2.stg_specific_table_ftwet_sum b -where F1_source=column2 -and b.is_rownumber_fetched is null) -where a.row_number_start is null -and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_staging2.stg_specific_table_ftwet_sum a -set is_rownumber_fetched=1 -from mmt_ods.mmt_config b -where F1_source=column2 -and b.row_number_start=a.row_number -and is_rownumber_fetched is null and -a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1 -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -execute 'update mmt_ods.mmt_config a -set row_read_end= (select b.row_number_start -from mmt_ods.mmt_config b -where b.syspk=a.syspk+1 ) -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a set row_read_end = null where f1_modified =''Test Manager Comments'' and -a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a -set run_time=current_timestamp -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'insert into mmt_staging2.stg_process_table_ftwet_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftwet_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Tractor Model'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - - -execute 'insert into mmt_staging2.stg_process_table_ftwet_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftwet_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Make of Implement'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_ftwet_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftwet_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Type of Cage Wheel'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_ftwet_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftwet_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Condition:'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_ftwet_sum -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftwet_sum a -join mmt_ods.mmt_config b -on a.row_number >=row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Test Manager Comments'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - -insert into mmt_staging2.FTWET_SUM_Trac_H1_Block -( -Tractor_Model, -Tractor_Make, -Tractor_Engine_HP, -Rated_RPM, -Transmission_Type, -Wheel_Drive_Type, -FIP_Type, -Steering_Type, -Tractor_Weight_kg_Front, -Tractor_Weight_kg_Rear, -Tractor_Weight_kg_Total -) -select column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12 -from mmt_staging2.stg_process_table_FTWET_sum -where rank_tag='FTWET_SUM_Trac_H1' and rank <> 1; - -/*delete from mmt_staging2.FTWET_SUM_Trac_H1_Block where dummy_f is null ; */ -execute 'update mmt_staging2.FTWET_SUM_Trac_H1_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - -insert into mmt_staging2.FTWET_SUM_Implement_Block -( -Make_of_Implement, -Implement_Type, -Implement_Size, -Hitch_Category, -Implement_Weight, -Soil_Type, -Moisture_Content , -Bulk_Density_g_cc , -Soil_Cone_index, -Field_Condition , -Season -) -select column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12 -from mmt_staging2.stg_process_table_FTWET_sum -where rank_tag='FTWET_SUM_Implement' and rank <> 1; - ---delete from mmt_staging2.FTWET_SUM_Implement_Block where dummy_f is null ; - -execute 'update mmt_staging2.FTWET_SUM_Implement_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -insert into mmt_staging2.FTWET_SUM_Cage_Wheel_Block -( -Type_of_Cage_Wheel, -Cage_Wheel_Width_mm, -Cage_wheel_Weight, -Cage_Wheel_inner_Outer_Ring_Dia_mm, -Cage_Wheel_Center_Ring_Dia_mm, -Distance_between_RHS_LHS_cage_wheel_Inner_Ring_mm, -No_of_angles_on_cage_wheel -) -select column2,column3,column4,column5,column6,column7,column8 -from mmt_staging2.stg_process_table_FTWET_sum -where rank_tag='FTWET_SUM_Cage_Wheel' and rank not in (1,3); - - -/*delete from mmt_staging2.FTWET_SUM_Cage_Wheel_Block where dummy_f is null ; */ -execute 'update mmt_staging2.FTWET_SUM_Cage_Wheel_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -insert into mmt_staging2.FTWET_SUM_Test_Condition_Block -( -dummy_f, -Test_Condition, -Test_Date, -Tractor_Model, -Engine_RPM_set, -PTO_RPM_set, -Gear_Used, -Nominal_Speed_KMPH, -Engine_RPM_Drop_on_straight_1st_Pass, -Engine_RPM_Drop_on_straight_2nd_Pass, -Engine_RPM_Drop_on_straight_3rd_Pass, -Engine_RPM_Drop_on_turn_1st_Pass, -Engine_RPM_Drop_on_turn_2nd_Pass, -Engine_RPM_Drop_on_turn_3rd_Pass, -No_of_passes, -Avg_Depth_of_cut_cm, -Fuel_consumption_lit_hr, -Area_covered_acr_hr, -Fuel_consumption_lit_Acr, -M_M_Performance_in_compared_to_respective_competitor_tractors, -Fuel_consumption_lit_hr_2, -Area_covered_acr_hr_2, -Fuel_consumption_lit_Acr_2, -Trail_Observations, -Engine_Smoke_on_Load, -Engine_acceleration_smoke, -Draft_Response, -Tractor_Steer_ability, -Tractor_braking_performance, -Front_Visibility, -Implement_Accessibility, -Front_Wheel_dragging_at_turning, -Front_end_lifting_during_operation, -RPM_Recovery_Time, -Engine_Vibration, -Engine_Sound, -Implement_Lifting_Lowering_response, -Pulverization_Quality, -Pulverization_Index -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3,column4,column5,column6,column7,column8,column9,column10,column11,column12}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text, -column4::text,column5::text,column6::text,column7::text,column8::text, -column9::text,column10::text,column11::text,column12::text]) AS val - FROM mmt_staging2.stg_process_table_ftwet_sum where rank_tag=''FTWET_SUM_Test_Condition'' - ORDER BY generate_series(1,15),2' - ) t (ccol text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text,a_10 text, - a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,a_18 text,a_19 text,a_20 text - ,a_21 text,a_22 text,a_23 text,a_24 text,a_25 text,a_26 text,a_27 text,a_28 text,a_29 text,a_30 text, -a_31 text,a_32 text,a_33 text,a_34 text,a_35 text,a_36 text,a_37 text,a_38 text); - - -delete from mmt_staging2.FTWET_SUM_Test_Condition_Block where dummy_f is null ; -execute 'update mmt_staging2.FTWET_SUM_Test_Condition_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -insert into mmt_staging2.FTWET_SUM_Comments_By_Block (dummy_f) values ('dummy'); - - -execute 'update mmt_staging2.FTWET_SUM_Comments_By_Block set test_manager_comments= -(select column3 from mmt_staging2.stg_process_table_FTWET_sum a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.rank_tag=''FTWET_SUM_Manager_Comments'' -and a.rank=1 ) where dummy_f=''dummy'''; - - -delete from mmt_staging2.FTWET_SUM_Comments_By_Block where dummy_f is null ; -execute 'update mmt_staging2.FTWET_SUM_Comments_By_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - -end -$$ LANGUAGE plpgsql; - -select mmt_staging2.fn_FTWET_SUM_Block(20,1,'FTWET','FTWET_SUM',181) - - diff --git a/MMT_SQL/staging2/wet_trs_execute.sql b/MMT_SQL/staging2/wet_trs_execute.sql deleted file mode 100644 index b072ac2..0000000 --- a/MMT_SQL/staging2/wet_trs_execute.sql +++ /dev/null @@ -1,342 +0,0 @@ - -/*FTWET_TRS starts*/ - -drop function if exists mmt_staging2.fn_FTWET_TRS_Block ; -CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTWET_TRS_Block(p_client_id int,p_function_id int, p_file_format text, -p_sheet_mnemonic text, p_file_syspk int) - RETURNS void AS $$ - begin - -SET search_path TO mmt_staging2; - -delete from mmt_staging2.FTWET_TRS_H1_INT; -delete from mmt_staging2.FTWET_TRS_H1_Block; -delete from mmt_staging2.FTWET_TRS_Engine_RPM_Block; -delete from mmt_staging2.FTWET_TRS_Implement_Block; -delete from mmt_staging2.stg_specific_table_ftwet_trs; -delete from mmt_staging2.stg_process_table_ftwet_trs; - -execute 'update mmt_ods.mmt_config a -set row_number_start=null, -row_previous_number=null, -row_read_end=null, -run_time=null -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'insert into mmt_staging2.stg_specific_table_ftwet_trs -select * from mmt_staging1.mmt_staging_generic_table a -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''' -and a.file_syspk='||p_file_syspk||''; - -update mmt_staging2.stg_specific_table_ftwet_trs set column2 = TRIM (TRAILING FROM column2 ); -update mmt_staging2.stg_specific_table_ftwet_trs set column2 = TRIM (LEADING FROM column2 ); - - - -update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified); -update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified); -update mmt_ods.mmt_config set F1_source=F1_modified ; -update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source); -update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source); - -execute 'update mmt_ods.mmt_config a -set row_number_start=(select min(b.row_number) -from mmt_staging2.stg_specific_table_ftwet_trs b -where upper(trim(F1_source))=upper(trim(column2)) -and b.is_rownumber_fetched is null) -where a.row_number_start is null -and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_staging2.stg_specific_table_ftwet_trs a -set is_rownumber_fetched=1 -from mmt_ods.mmt_config b -where upper(trim(F1_source))=upper(trim(column2)) -and b.row_number_start=a.row_number -and is_rownumber_fetched is null -and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1 -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -execute 'update mmt_ods.mmt_config a -set row_read_end= (select b.row_number_start -from mmt_ods.mmt_config b -where b.syspk=a.syspk+1 ) -where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a set row_read_end = null where f1_modified =''Implement Details'' -and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'update mmt_ods.mmt_config a -set run_time=current_timestamp where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||''''; - -execute 'insert into mmt_staging2.stg_process_table_ftwet_trs -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftwet_trs a -join mmt_ods.mmt_config b -on a.row_number >row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Tractor Specifications Sheet'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - - -execute 'insert into mmt_staging2.stg_process_table_ftwet_trs -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftwet_trs a -join mmt_ods.mmt_config b -on a.row_number >row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Tractor Specifications'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_ftwet_trs -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftwet_trs a -join mmt_ods.mmt_config b -on a.row_number >row_number_start -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Engine RPM Data:'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - -execute 'insert into mmt_staging2.stg_process_table_ftwet_trs -select a.* , RANK () OVER ( ORDER BY row_number),b.rank_tag as rank_tag -from mmt_staging2.stg_specific_table_ftwet_trs a -join mmt_ods.mmt_config b -on a.row_number >row_number_start -and a.column2 <> '''' -and (a.row_number< row_read_end or row_read_end is null) -and f1_modified=''Implement Details'' and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||''' -order by a.row_number'; - - -insert into mmt_staging2.FTWET_TRS_H1_INT(column2,column3,column4,column5,column6,column7) -select column2,column3,column4,column5,column6,column7 from mmt_staging2.stg_process_table_ftwet_trs a -where rank_tag='FTWET_TRS_H1'; - - -insert into mmt_staging2.FTWET_TRS_H1_INT(column2) values ('Date of Test'); - -insert into mmt_staging2.FTWET_TRS_H1_INT(column2) values ('Report Date'); - -insert into mmt_staging2.FTWET_TRS_H1_INT(column2) values ('Season'); - -insert into mmt_staging2.FTWET_TRS_H1_INT (column2) values ('Type of Soil'); - -insert into mmt_staging2.FTWET_TRS_H1_INT (column2) values ('Soil Cone Index (kPa)'); - -insert into mmt_staging2.FTWET_TRS_H1_INT (column2) values ('Field Condition'); - -update mmt_staging2.FTWET_TRS_H1_INT a -set column3=(select column5 from mmt_staging2.FTWET_TRS_H1_INT b -where trim(a.column2)=trim(b.column4) -and b.column4='Date of Test') -where a.column2='Date of Test'; - -update mmt_staging2.FTWET_TRS_H1_INT a -set column3=(select column7 from mmt_staging2.FTWET_TRS_H1_INT b -where trim(a.column2)=trim(b.column6) -and b.column6='Report Date') -where a.column2='Report Date'; - -update mmt_staging2.FTWET_TRS_H1_INT a -set column3=(select column6 from mmt_staging2.FTWET_TRS_H1_INT b -where trim(a.column2)=trim(b.column5) -and b.column5='Season') -where a.column2='Season'; - -update mmt_staging2.FTWET_TRS_H1_INT a -set column3=(select column6 from mmt_staging2.FTWET_TRS_H1_INT b -where trim(a.column2)=trim(b.column5) -and b.column5='Type of Soil') -where a.column2='Type of Soil'; - - -update mmt_staging2.FTWET_TRS_H1_INT a -set column3=(select column6 from mmt_staging2.FTWET_TRS_H1_INT b -where trim(a.column2)=trim(b.column5) -and b.column5='Soil Cone Index (kPa)') -where a.column2='Soil Cone Index (kPa)'; - - -update mmt_staging2.FTWET_TRS_H1_INT a -set column3=(select column6 from mmt_staging2.FTWET_TRS_H1_INT b -where trim(a.column2)=trim(b.column5) -and b.column5='Field Condition') -where a.column2='Field Condition'; - -insert into mmt_staging2.FTWET_TRS_H1_Block -( -dummy_f, -Report_Reference_No, -Objective_Of_Test, -Background_of_Test, -Job_Order_No, -Test_Location, -Soil_Moisture_Content_, -Soil_Bulk_Density_g_cc, -Test_Engineer, -Test_Operator, -Date_of_Test, -Report_Date, -Season, -Type_of_Soil, -Soil_Cone_Index_kPa, -Field_Condition -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text]) AS val - FROM mmt_staging2.FTWET_TRS_H1_INT - ORDER BY generate_series(1,15),2' - ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text,a_10 text, - a_11 text,a_12 text,a_13 text,a_14 text,a_15 text); - - - -delete from mmt_staging2.FTWET_TRS_H1_Block where dummy_f is null ; -execute 'update mmt_staging2.FTWET_TRS_H1_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - - -insert into mmt_staging2.FTWET_TRS_SPEC_Block -( -dummy_f, -Tractor_Model, -Tractor_Make, -Tractor_Sr_No, -Tractor_Engine_HP, -FIP_Type, -hour_Meter_Reading, -Steering_Type, -Transmission_Type, -Wheel_Drive_Type_WD, -EGR_Yes_No, -Brake_Type, -PTO_Type, -Standard_PTO_Speed_RPM, -EPTO_Speed_RPM, -Front_Tyre_Make, -Front_Tyre_Size, -Front_Tyre_Pressure_psi, -Rear_Tyre_Make, -Rear_Tyre_Size, -Rear_Tyre_Pressure_psi , -Tractor_Weight_kg_Front , -Tractor_Weight_kg_Rear , -Tractor_Weight_kg_Total, -Ballasted_Tractor_Accessories, -Mechanical_Ballast_Rear_in_KG , -Water_Ballast_Rear, -Mechanical_Ballast_Front, -Mechanical_Ballast_Front_in_Kg, -Total_Ballast_Weight -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3,column4,column5,column6,column7}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text,column4::text,column5::text,column6::text,column7::text]) AS val - FROM mmt_staging2.stg_process_table_ftwet_trs where rank_tag=''FTWET_TRS_SPEC'' - ORDER BY generate_series(1,15),2' - ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text, - a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,a_18 text,a_19 text,a_20 text,a_21 text, - a_22 text,a_23 text,a_24 text,a_25 text,a_26 text,a_27 text,a_28 text,a_29 text); - - - -delete from mmt_staging2.FTWET_TRS_SPEC_Block where dummy_f is null ; -execute 'update mmt_staging2.FTWET_TRS_SPEC_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - -insert into mmt_staging2.FTWET_TRS_Engine_RPM_Block -( -dummy_f, -Tractor_model, -Tractor_make, -Low_Idle, -High_Idle, -Rated_RPM, -Engine_to_PTO_Ratio_540_PTO, -Engine_to_PTO_Ratio_540E_PTO -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3,column4,column5,column6,column7}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text,column4::text,column5::text,column6::text,column7::text]) AS val - FROM mmt_staging2.stg_process_table_ftwet_trs where rank_tag=''FTWET_TRS_Engine_RPM'' - or (rank_tag=''FTWET_TRS_SPEC'' and rank in (1,2)) - ORDER BY generate_series(1,15),2' - ) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text); - - - -delete from mmt_staging2.FTWET_TRS_Engine_RPM_Block where dummy_f is null ; -execute 'update mmt_staging2.FTWET_TRS_Engine_RPM_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - -insert into mmt_staging2.FTWET_TRS_Implement_Block -( -dummy_f, -Name_of_Implement, -Type_of_Implement, -Make_of_Implement, -No_of_bottoms_Tyne_Disc_Blade, -Cutting_Width_m, -Implement_Weight_Kg, -Hitch_Category, -Span_cm_For_Mounted_Implement, -Mast_Height_cm_For_Mounted_Implement, -Type_of_Cage_Wheel_Half_Cage_wheel_Full_Cage_Wheel, -Cage_Wheel_Width_mm, -Cage_wheel_Weight, -Cage_Wheel_inner_Outer_Ring_Dia_mm, -Cage_Wheel_Center_Ring_Dia_mm, -Distance_between_RHS_LHS_cage_wheel_Inner_Ring_mm_For_Full_Cage_wheel, -No_of_angles_on_cage_wheel, -No_of_days_of_water_logging, -Depth_of_water_mm , -FDPD_TDC_Mar15_008 -) -SELECT * -FROM crosstab( - 'SELECT unnest(''{column3,column4,column5,column6}''::text[]) AS col - , row_number() OVER () - , unnest(ARRAY[column3::text,column4::text,column5::text,column6::text]) AS val - FROM mmt_staging2.stg_process_table_ftwet_trs where rank_tag=''FTWET_TRS_Implement'' - ORDER BY generate_series(1,15),2' - ) t ( col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text - ,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,a_18 text,a_19 text); - - -delete from mmt_staging2.FTWET_TRS_Implement_Block where dummy_f is null ; -execute 'update mmt_staging2.FTWET_TRS_Implement_Block set -client_id='||p_client_id||', -function_id='||p_function_id||', -file_syspk='||p_file_syspk||', -file_format='''||p_file_format||''', -sheet_mnemonic='''||p_sheet_mnemonic||''''; - -end -$$ LANGUAGE plpgsql; - -select mmt_staging2.fn_FTWET_TRS_Block -(20,1,'FTWET','FTWET_TRS',181); -/*FTWET_TRS ends*/ -