folder name changed

This commit is contained in:
Deepthi
2021-04-27 16:41:49 +05:30
parent c8985b2d62
commit 559fa36e6a
71 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,208 @@
drop function if exists mmt_staging2.fn_BUDNI_ARC_ODS;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_BUDNI_ARC_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_BUDNI_ARC_ODS
Function Desc: This function populates data into ODS
File Format: BUDNI
Sheet Format: BUDNI_ARC
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_BUDNI_ARC_ODS()
***************************************************************/
delete from mmt_ods.test_instance where test_file_sheet_format='BUDNI_ARC';
delete from mmt_ods.test_instance_engine_info where test_file_sheet_format='BUDNI_ARC';
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='BUDNI_ARC';
delete from mmt_ods.budni_air_cleaner_perf_results where test_file_sheet_format='BUDNI_ARC';
delete from mmt_ods.budni_test_observations where test_file_sheet_format='BUDNI_ARC';
SET search_path TO mmt_staging2;
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,
tractor_engine_hp,
configuration,
transmission_type,
wheel_drive_type,
fip_type,
steering_type,
ballast_condition
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,
model,
tractor_HP::int tractor_engine_hp,
configuration,
transmission_type,
wheel_drive_type,
FIP_type,
steering_type,
Ballast_Condition
from mmt_staging2.BUDNI_ARC_Spec_H1_block;
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,
make,model,
type_of_track
from
mmt_staging2.BUDNI_ARC_Spec_H1_block;
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,
make,model,
rated_rpm::int,
engine_to_pto_ratio engine_to_pto_ratio_540_pto
from mmt_staging2.BUDNI_ARC_Spec_H1_block;
/*block */
insert into mmt_ods.budni_air_cleaner_perf_results
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
atm_condtion_temperature_c,
atm_condition_pressure_kpa,
atm_condition_relative_humidity_pct,
atm_condtion_mass_of_oil_before_test,
position_of_tractor,
loss_of_oil_g,
oil_pull_over_pct,
engine_oil_pressure
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
Temperature_C,
Pressure_kPa,
Relative_humidity::numeric,
Mass_of_oil_before_test::numeric,
Position_of_tractor,
Loss_of_oil::numeric,
Oil_pull_Over::numeric,
Engine_oil_pressure
from mmt_staging2.budni_arc_perf_atmos_meas_test_block where ods_record=1
order by rank;
insert into mmt_ods.budni_test_observations
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
sequence_number,
characteristic,
category_evaluative_or_non_evaluative,
requirements_as_per_is_12207_2008,
values_declared_by_the_applicant_d_rqmt,
as_observed,
whether_meets_the_requirements_yn
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
column3::int,
column4,
column5,
column6,
column7,
column8,
column9
from mmt_staging2.BUDNI_ARC_test_obs_summary_block where ods_record=1;
select file_syspk into __file_syspk from mmt_staging2.BUDNI_ARC_Spec_H1_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.test_instance_engine_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_air_cleaner_perf_results
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_test_observations
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,462 @@
drop function if exists mmt_staging2.fn_BUDNI_BRK_ODS;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_BUDNI_BRK_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_BUDNI_BRK_ODS
Function Desc: This function populates data into ODS
File Format: BUDNI
Sheet Format: BUDNI_BRK
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_BUDNI_BRK_ODS()
***************************************************************/
delete from mmt_ods.test_instance where test_file_sheet_format='BUDNI_BRK';
delete from mmt_ods.test_instance_engine_info where test_file_sheet_format='BUDNI_BRK';
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='BUDNI_BRK';
delete from mmt_ods.budni_brake_perf_parking_brake_test_results
where test_file_sheet_format='BUDNI_BRK';
delete from mmt_ods.budni_brake_perf_service_brake_test_results
where test_file_sheet_format='BUDNI_BRK';
delete from mmt_ods.budni_test_observations
where test_file_sheet_format='BUDNI_BRK';
SET search_path TO mmt_staging2;
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,
tractor_engine_hp,
brake_type,
brake_free_play_lh,
brake_free_play_rh,
unballasted_max_speed_kmph,
road_ballasted_max_speed_kmph
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,
model,
tractor_HP::numeric tractor_engine_hp,
Type_of_brake,
brake_free_play_lh::numeric ,
brake_free_play_rh::numeric ,
maximum_attainable_speed_kmph_unballasted::numeric ,
maximum_attainable_speed_kmph_ballasted::numeric
from mmt_staging2.BUDNI_BRK_Spec_H1_block;
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,
make,model,
type_of_track
from
mmt_staging2.BUDNI_BRK_Spec_H1_block;
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
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
rated_rpm::int
from mmt_staging2.BUDNI_BRK_Spec_H1_block;
/*block */
insert into mmt_ods.budni_brake_perf_service_brake_test_results
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
brake_test_type,
brake_test_name,
speed_condition,
ballast_condition,
braking_device_control_force_n,
mean_deceleration_msec2,
stopping_dist_m
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
brake_test_type,
brake_test_name,
speed_condition,
ballast_condition,
Braking_device_control_force_N::numeric ,
Mean_deceleration_m_sec2::numeric ,
Stopping_distance_m ::numeric
from mmt_staging2.budni_brk_service_cold_ballasted_25kmph_block;
insert into mmt_ods.budni_brake_perf_service_brake_test_results
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
brake_test_type,
brake_test_name,
speed_condition,
ballast_condition,
braking_device_control_force_n,
mean_deceleration_msec2,
stopping_dist_m
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
brake_test_type,
brake_test_name,
speed_condition,
ballast_condition,
Braking_device_control_force_N::numeric ,
Mean_deceleration_m_sec2::numeric ,
Stopping_distance_m ::numeric
from mmt_staging2.budni_brk_service_cold_ballasted_maximum_block;
insert into mmt_ods.budni_brake_perf_service_brake_test_results
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
brake_test_type,
brake_test_name,
speed_condition,
ballast_condition,
braking_device_control_force_n,
mean_deceleration_msec2,
stopping_dist_m
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
brake_test_type,
brake_test_name,
speed_condition,
ballast_condition,
Braking_device_control_force_N::numeric ,
Mean_deceleration_m_sec2::numeric ,
Stopping_distance_m ::numeric
from mmt_staging2.budni_brk_service_cold_standard_25kmph_block;
insert into mmt_ods.budni_brake_perf_service_brake_test_results
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
brake_test_type,
brake_test_name,
speed_condition,
ballast_condition,
braking_device_control_force_n,
mean_deceleration_msec2,
stopping_dist_m
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
brake_test_type,
brake_test_name,
speed_condition,
ballast_condition,
Braking_device_control_force_N::numeric ,
Mean_deceleration_m_sec2::numeric ,
Stopping_distance_m ::numeric
from mmt_staging2.budni_brk_service_cold_standard_maximum_block;
insert into mmt_ods.budni_brake_perf_service_brake_test_results
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
brake_test_type,
brake_test_name,
speed_condition,
ballast_condition,
braking_device_control_force_n,
mean_deceleration_msec2,
stopping_dist_m
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
brake_test_type,
brake_test_name,
speed_condition,
ballast_condition,
Braking_device_control_force_N::numeric ,
Mean_deceleration_m_sec2::numeric ,
Stopping_distance_m ::numeric
from mmt_staging2.budni_brk_service_fade_standard_maximum_block;
insert into mmt_ods.budni_brake_perf_service_brake_test_results
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
brake_test_type,
brake_test_name,
speed_condition,
ballast_condition,
braking_device_control_force_n,
mean_deceleration_msec2,
stopping_dist_m
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
brake_test_type,
brake_test_name,
speed_condition,
ballast_condition,
Braking_device_control_force_N::numeric ,
Mean_deceleration_m_sec2::numeric ,
Stopping_distance_m ::numeric
from mmt_staging2.budni_brk_service_fade_ballasted_25kmph_block;
update mmt_ods.budni_brake_perf_service_brake_test_results
set max_dev_of_tractor_from_its_org_course_m =column3,
abnormal_vibration=column5,
the_brakes_were_heated_by =column7
from mmt_staging2.budni_brk_other_observations_Block where ods_record =1;
insert into mmt_ods.budni_brake_perf_parking_brake_test_results
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
test_condition
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
particulars
from mmt_staging2.budni_brk_parking_barke_test_block where particulars is not null;
update mmt_ods.budni_brake_perf_parking_brake_test_results
set braking_device_control_force_n_facing_up = (select
Braking_device_control_force::numeric
from mmt_staging2.budni_brk_parking_barke_test_block
where facing='Facing up' and particulars='18 percent slope')
where test_condition='18 percent slope';
update mmt_ods.budni_brake_perf_parking_brake_test_results
set braking_device_control_force_n_facing_down = (select
Braking_device_control_force::numeric
from mmt_staging2.budni_brk_parking_barke_test_block
where facing='Facing Down' and particulars='18 percent slope')
where test_condition='18 percent slope';
update mmt_ods.budni_brake_perf_parking_brake_test_results
set efficacy_of_parking_brake_facing_down = (select
Efficacy_of_parking_brake
from mmt_staging2.budni_brk_parking_barke_test_block
where facing='Facing Down' and particulars='18 percent slope')
where test_condition='18 percent slope';
update mmt_ods.budni_brake_perf_parking_brake_test_results
set efficacy_of_parking_brake_facing_up = (select
Efficacy_of_parking_brake
from mmt_staging2.budni_brk_parking_barke_test_block
where facing='Facing up' and particulars='18 percent slope')
where test_condition='18 percent slope';
update mmt_ods.budni_brake_perf_parking_brake_test_results
set braking_device_control_force_n_facing_up = (select
Braking_device_control_force::numeric
from mmt_staging2.budni_brk_parking_barke_test_block
where facing='Facing up' and particulars='12 percent slope with trailer of 2.55 tonnes.')
where test_condition='12 percent slope with trailer of 2.55 tonnes.';
update mmt_ods.budni_brake_perf_parking_brake_test_results
set braking_device_control_force_n_facing_down = (select
Braking_device_control_force::numeric
from mmt_staging2.budni_brk_parking_barke_test_block
where facing='Facing Down' and particulars='12 percent slope with trailer of 2.55 tonnes.')
where test_condition='12 percent slope with trailer of 2.55 tonnes.';
update mmt_ods.budni_brake_perf_parking_brake_test_results
set efficacy_of_parking_brake_facing_down = (select
Efficacy_of_parking_brake
from mmt_staging2.budni_brk_parking_barke_test_block
where facing='Facing Down' and particulars='12 percent slope with trailer of 2.55 tonnes.')
where test_condition='12 percent slope with trailer of 2.55 tonnes.';
update mmt_ods.budni_brake_perf_parking_brake_test_results
set efficacy_of_parking_brake_facing_up = (select
Efficacy_of_parking_brake
from mmt_staging2.budni_brk_parking_barke_test_block
where facing='Facing up' and particulars='12 percent slope with trailer of 2.55 tonnes.')
where test_condition='12 percent slope with trailer of 2.55 tonnes.';
delete from mmt_ods.budni_brake_perf_parking_brake_test_results a
using mmt_ods.budni_brake_perf_parking_brake_test_results b
where a.syspk < b.syspk and a.test_condition =b.test_condition ;
insert into mmt_ods.budni_test_observations
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
characteristic,
category_evaluative_or_non_evaluative,
requirements_as_per_is_12207_2008,
values_declared_by_the_applicant_d_rqmt,
as_observed,
whether_meets_the_requirements_yn
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
column3,
column4,
column5,
column6,
column7,
column8
from mmt_staging2.BUDNI_BRK_test_obs_summary_block where ods_record=1;
select file_syspk into __file_syspk from mmt_staging2.BUDNI_BRK_Spec_H1_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.test_instance_engine_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_brake_perf_parking_brake_test_results
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_brake_perf_service_brake_test_results
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_test_observations
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,162 @@
drop function if exists mmt_staging2.fn_BUDNI_DBP_ODS ;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_BUDNI_DBP_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_BUDNI_DBP_ODS
Function Desc: This function populates data into ODS
File Format: BUDNI
Sheet Format: BUDNI_DBP
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_BUDNI_DBP_ODS()
***************************************************************/
delete from mmt_ods.test_instance where test_file_sheet_format='BUDNI_DBP';
delete from mmt_ods.test_instance_engine_info where test_file_sheet_format='BUDNI_DBP';
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='BUDNI_DBP';
delete from mmt_ods.budni_drawbar_perf_results where test_file_sheet_format='BUDNI_DBP';
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_mm,
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_hr,
drawbar_power_kw,
drawbar_pull_kn,
engine_speed_rpm,
wheel_slippage_pct ,
fuel_consumption_kg_per_kwh,
fuel_consumption_ltr_per_hr ,
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;
select file_syspk into __file_syspk from mmt_staging2.BUDNI_DBP_Spec_H1_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.test_instance_engine_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_drawbar_perf_results
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,317 @@
drop function if exists mmt_staging2.fn_budni_fld_ODS;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_budni_fld_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_BUDNI_FLD_ODS
Function Desc: This function populates data into ODS
File Format: BUDNI
Sheet Format: BUDNI_FLD
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_BUDNI_FLD_ODS()
***************************************************************/
delete from mmt_ods.test_instance where test_file_sheet_format='BUDNI_FLD';
delete from mmt_ods.test_instance_engine_info where test_file_sheet_format='BUDNI_FLD';
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='BUDNI_FLD';
delete from mmt_ods.test_instance_implement_info where test_file_sheet_format='BUDNI_FLD';
delete from mmt_ods.budni_field_perf_results where test_file_sheet_format='BUDNI_FLD';
delete from mmt_ods.budni_test_observations where test_file_sheet_format='BUDNI_FLD';
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,
tractor_engine_hp,
configuration,
transmission_type,
wheel_drive_type,
fip_type,
steering_type,
ballast_condition
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,
model,
tractor_HP::int tractor_engine_hp,
configuration,
transmission_type,
wheel_drive_type,
FIP_type,
steering_type,
Ballast_Condition
from mmt_staging2.budni_fld_Spec_H1_block;
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
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model
from
mmt_staging2.budni_fld_Spec_H1_block;
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,
make,model,
rated_rpm::int,
engine_to_pto_ratio engine_to_pto_ratio_540_pto
from mmt_staging2.budni_fld_Spec_H1_block;
insert into mmt_ods.test_instance_implement_info
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
name_of_implement,
make_of_implement,
type_of_implement,
no_of_disc_blades_bottoms,
type_of_disc_blades_bottoms,
size_of_bottoms_blades_mm,
size_of_bottoms_blades2_mm,
size_of_bottoms_blades3_mm,
spacing_of_bottoms_flanges_mm,
span_for_mounted_implement_mm,
mast_height_for_mounted_implement_mm,
length_mm,
width_mm,
height_mm,
gross_mass_kg
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
items,
Make,
type,
No_of_Disc_blades,
Type_of_Disc_blades,
Size_of_bottoms_blades_1_mm::numeric,
Size_of_bottoms_blades_2_mm::numeric,
Size_of_bottoms_blades_3_mm::numeric,
Spacing_of_bottoms_flanges_mm::numeric,
Lower_hitch_point_span_mm::numeric,
Mast_height_mm,
Overall_dimensions_mm_length::numeric,
Overall_dimensions_mm_Width::numeric,
Overall_dimensions_mm_Height::numeric,
Gross_mass_kg::numeric
from mmt_staging2.BUDNI_FLD_Impl_Test_Block
order by rank;
insert into mmt_ods.test_instance_implement_info
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
name_of_implement,
type_of_implement,
cage_wheel_dia_mm,
cage_wheel_width_mm,
no_and_types_of_lugs,
size_of_angle_section_mm,
size_of_angle_section2_mm,
size_of_angle_section3_mm,
length_of_lugs_mm,
spacing_of_lugs_mm,
cage_wheel_weight_kg
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
Items,
type,
Dia_mm::numeric,
Width_mm::numeric,
No_and_types_of_lugs,
Size_of_angle_section_1_mm::numeric,
Size_of_angle_section_2_mm::numeric,
Size_of_angle_section_3_mm::numeric,
Length_of_lugs_mm::numeric,
Spacing_of_lugs_mm::numeric,
Weight_of_each_cage_wheels_kg::numeric
from mmt_staging2.BUDNI_FLD_Cage_Wheel_Block
order by rank;
insert into mmt_ods.budni_field_perf_results
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
operation_type,
type_of_soil,
avg_soil_moisture_pct_,
bulk_density_of_soil_g_per_cc,
cone_index_kgf_per_sq_cm,
gear_used,
avg_speed_of_operation_kmph,
avg_travel_reduction_pct,
avg_depth_of_puddle_cm,
avg_working_width_cm,
area_covered_ha_per_hr,
fuel_consumption_ltr_per_hr,
fuel_consumption_ltr_per_ha,
avg_draft_of_implement_kn
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,
model,
Parameter_operation,
Type_of_soil,
Av_soil_moisture_Av_depth_of_standing_water_cm,
Bulk_density_of_soil_g_cc,
Cone_index_kgf_sq_cm_Puddling_index,
Gear_used,
Av_speed_of_operation_kmph,
Av_wheel_slip_Av_Travel_reduction,
Av_depth_of_cut_cm_Av_Depth_of_puddle_cm,
Av_working_width_cm,
Area_covered_ha_h,
Fuel_consumption_l_h,
Fuel_consumption_l_ha,
Av_draft_of_implement_kN
from mmt_staging2.BUDNI_FLD_Sum_Perf_Test_Block;
insert into mmt_ods.budni_test_observations
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
srl_no,
characteristic,
category_evaluative_or_non_evaluative,
requirements_as_per_is_12207_2008,
values_declared_by_the_applicant_d_rqmt,
as_observed,
whether_meets_the_requirements_yn
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
column3,
column4,
column5,
column6,
column7,
column8,
column9
from mmt_staging2.budni_fld_test_obs_summary_block where ods_record=1;
select file_syspk into __file_syspk from mmt_staging2.BUDNI_FLD_Spec_H1_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.test_instance_engine_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_implement_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_field_perf_results
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_test_observations
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,330 @@
drop function if exists mmt_staging2.fn_BUDNI_HDL_ODS;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_BUDNI_HDL_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_BUDNI_HDL_ODS
Function Desc: This function populates data into ODS
File Format: BUDNI
Sheet Format: BUDNI_HDL
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_BUDNI_HDL_ODS()
***************************************************************/
delete from mmt_ods.test_instance
where test_file_sheet_format='BUDNI_HDL';
delete from mmt_ods.test_instance_engine_info
where test_file_sheet_format='BUDNI_HDL';
delete from mmt_ods.test_instance_tractor_info
where test_file_sheet_format='BUDNI_HDL';
delete from mmt_ods.test_instance_tractor_info_misc
where test_file_sheet_format='BUDNI_HDL';
delete from mmt_ods.budni_hydraulic_maint_of_lift_load_results
where test_file_sheet_format='BUDNI_HDL';
delete from mmt_ods.budni_hydraulic_power_test_results
where test_file_sheet_format='BUDNI_HDL';
delete from mmt_ods.budni_hydraulic_lifting_capacity_test_results
where test_file_sheet_format='BUDNI_HDL';
delete from mmt_ods.budni_test_observations
where test_file_sheet_format='BUDNI_HDL';
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,
tractor_engine_hp,
steering_type
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
tractor_make,
tractor_model,
tractor_HP::int,
steering_type
from mmt_staging2.BUDNI_HDL_Spec_H1_block;
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
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
tractor_make,
tractor_model
from
mmt_staging2.BUDNI_HDL_Spec_H1_block;
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
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
tractor_make,
tractor_model,
rated_rpm::int
from mmt_staging2.BUDNI_HDL_Spec_H1_block;
insert into mmt_ods.test_instance_tractor_info_misc
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
hydraulic_type,
pump_speed_at_rated_engine_speed_rpm,
oil,
lift_rod_type_lh,
lift_rod_type_rh,
lift_rod_length_lh,
lift_rod_length_rh,
lower_link_length_lh,
lower_link_length_rh,
pump_hp
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
tractor_make,
tractor_model,
hydraulic_type,
Pump_speed_at_rated_engine_speed_rpm::numeric,
Oil,
Lift_Rod_type_LH,
Lift_Rod_type_RH,
Lift_Rod_Length_LH::numeric,
Lift_Rod_Length_RH::numeric,
Lower_link_Length_LH::numeric,
Lower_link_Length_RH::numeric,
Pump_HP::numeric
from mmt_staging2.BUDNI_HDL_Spec_H1_block;
/*block */
insert into mmt_ods.budni_hydraulic_power_test_results
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
pump_dlvry_rate_at_min_pressure_engine_speed_l_per_min,
max_hydraulic_power_kw,
pump_dlvry_rate_at_max_hydraulic_power_lmin,
sustained_pressure_of_the_open_relief_valve_mpa,
pressure_at_max_hydraulic_power_mpa,
tapping_point_relief_valve_test,
tapping_point_pump_perf_test,
tapping_point_temperature_of_hydraulic_fluid_c
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
Pump_delivery_rate_at_minimum_pressure_and_rated_engine_speed_l_min::numeric,
Maximum_hydraulic_power_kW::numeric,
Pump_delivery_rate_at_maximum_hydraulic_power_l_min::numeric,
Pressure_at_maximum_hydraulic_power_MPa::numeric,
Sustained_pressure_of_the_open_relief_valve_MPa::numeric,
tapping_point_relief_valve_test,
tapping_point_Pump_performance_test,
tapping_point_Temperature_of_hydraulic_fluid_C
from mmt_staging2.budni_hdl_power_test_block where ods_record=1
order by rank;
insert into mmt_ods.budni_hydraulic_maint_of_lift_load_results
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
force_applied_at_the_frame_kn,
temp_of_hydraulic_fluid_at_the_start_of_test_c,
elapsed_time_min,
cumulative_drop_in_height_of_lift_mm
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,
model,
Force_applied_at_the_frame_kN::numeric,
Temperature_of_hydraulic_fluid_at_the_start_of_test_C::numeric,
Elapsed_time_minute::numeric,
Cumulative_drop_in_height_of_lift_mm::numeric
from mmt_staging2.budni_hdl_maintenance_of_lift_load_block;
/*block */
insert into mmt_ods.budni_hydraulic_lifting_capacity_test_results
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
test_condition,
height_of_lower_hitch_pt_above_ground_in_down_position_mm,
vertical_move_ment_with_lifting_forces_mm,
max_force_exerted_through_full_range_kn,
corresponding_pressure_mpa,
moment_about_rear_axle_kn_m,
max_tilt_angle_of_mast_from_vertical_degrees
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,
model,
column5,
column6::numeric,
column7::numeric,
column8::numeric,
column9::numeric,
column10::numeric,
column11::numeric
from mmt_staging2.budni_hdl_Lifting_Capacity_Test_Block
where ods_record=1;
/* block */
insert into mmt_ods.budni_test_observations
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
srl_no,
characteristic,
category_evaluative_or_non_evaluative,
requirements_as_per_is_12207_2008,
values_declared_by_the_applicant_d_rqmt,
as_observed,
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_hdl_test_obs_summary_block
where ods_record=1
;
select file_syspk into __file_syspk from mmt_staging2.BUDNI_FLD_Spec_H1_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.test_instance_engine_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info_misc
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_hydraulic_maint_of_lift_load_results
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_hydraulic_power_test_results
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_hydraulic_lifting_capacity_test_results
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_test_observations
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,217 @@
drop function if exists mmt_staging2.fn_budni_hlg_ODS;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_budni_hlg_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_BUDNI_HLG_ODS
Function Desc: This function populates data into ODS
File Format: BUDNI
Sheet Format: BUDNI_HLG
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_BUDNI_HLG_ODS()
***************************************************************/
delete from mmt_ods.test_instance where test_file_sheet_format='BUDNI_HLG';
delete from mmt_ods.test_instance_engine_info where test_file_sheet_format='BUDNI_HLG';
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='BUDNI_HLG';
delete from mmt_ods.budni_haulage_perf_results where test_file_sheet_format='BUDNI_HLG';
delete from mmt_ods.budni_test_observations where test_file_sheet_format='BUDNI_HLG';
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,
tractor_engine_hp,
configuration,
transmission_type,
wheel_drive_type,
fip_type,
steering_type,
ballast_condition
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,
model,
tractor_HP::int tractor_engine_hp,
configuration,
transmission_type,
wheel_drive_type,
FIP_type,
steering_type,
Ballast_Condition
from mmt_staging2.budni_hlg_Spec_H1_block;
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,
make,model,
type_of_track
from
mmt_staging2.budni_hlg_Spec_H1_block;
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,
make,model,
rated_rpm::int,
engine_to_pto_ratio engine_to_pto_ratio_540_pto
from mmt_staging2.budni_hlg_Spec_H1_block;
/*block */
insert into mmt_ods.budni_haulage_perf_results
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
trailer_type,
gross_mass_of_trailer_tonne,
height_of_trailer_hitch_above_ground_level_mm,
gear_used_negotiating_slopes_up_to_8pct,
avg_travel_speed_kmph,
avg_fuel_consumption_ltr_per_hr,
avg_fuel_consumption_ml_per_km_per_tonne,
avg_dist_traveled_per_litre_of_fuel_consumption_km,
effectiveness_of_brakes,
maneuverability_of_tractor_trailer_combination
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
type_of_trailer,
Gross_mass_of_trailer_tonne::numeric,
Height_of_trailer_hitch_above_ground_level_mm::numeric,
Gear_used_during_the_test_for_negotiating_slopes_up_to_8,
Average_travel_speed_kmph,
l_h,
ml_km_tonne,
Average_distance_traveled_per_litre_of_fuel_consumption_km,
Effectiveness_of_brakes,
Maneuverability_of_tractor_trailer_combination
from mmt_staging2.BUDNI_HLG_Perf_Test_block where ods_record=1
order by rank;
insert into mmt_ods.budni_test_observations
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
sequence_number ,
characteristic,
category_evaluative_or_non_evaluative,
requirements_as_per_is_12207_2008,
values_declared_by_the_applicant_d_rqmt,
as_observed,
whether_meets_the_requirements_yn
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
column3::numeric ,
column4,
column5,
column6,
column7,
column8,
column9
from mmt_staging2.budni_hlg_test_obs_summary_block where ods_record=1;
select file_syspk into __file_syspk from mmt_staging2.BUDNI_FLD_Spec_H1_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.test_instance_engine_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_haulage_perf_results
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_test_observations
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,161 @@
drop function if exists mmt_staging2.fn_BUDNI_LCG_ODS ;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_BUDNI_LCG_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_BUDNI_LCG_ODS
Function Desc: This function populates data into ODS
File Format: BUDNI
Sheet Format: BUDNI_LCG
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_BUDNI_LCG_ODS()
***************************************************************/
delete from mmt_ods.test_instance where test_file_sheet_format='BUDNI_LCG';
delete from mmt_ods.test_instance_engine_info where test_file_sheet_format='BUDNI_LCG';
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='BUDNI_LCG';
delete from mmt_ods.budni_centre_of_gravity_location where test_file_ref_no =261;
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,
tractor_engine_hp,
configuration,
transmission_type,
wheel_drive_type,
wheel_base_mm,
wheel_track_mm,
overall_height_mm,
ballast_condition,
weight_reactions_front_kg,
weight_reactions_rear_kg
)
select
client_id,
function_id,
file_syspk ,
file_format,
sheet_mnemonic,
make,
model,
Tractor_HP::int tractor_engine_hp,
configuration,
Transmission_type,
Wheel_Drive_type,
Wheel_Base::int wheel_base_mm,
wheel_track::int wheel_track_mm,
overall_height::int,
Ballast_Condition,
Tractor_Weight_reactions_Front::int weight_reactions_front_kg ,
Tractor_Weight_reactions_Rear::int weight_reactions_rear_kg
from mmt_staging2.BUDNI_LCG_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
)
select
client_id,
function_id,
file_syspk ,
file_format,
sheet_mnemonic,
make,
model
from mmt_staging2.BUDNI_LCG_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
)
select
client_id,
function_id,
file_syspk ,
file_format,
sheet_mnemonic,
make,
model,
rated_rpm::int
from mmt_staging2.BUDNI_LCG_Spec_H1_Block where ods_record =1 ;
insert into mmt_ods.budni_centre_of_gravity_location
(
client_id,
function_id,
test_file_ref_no,
tractor_make,
tractor_model,
condition,
particulars,
coordinates
)
select
client_id,
function_id,
file_syspk ,
make,
model,
column3,
column6,
column8
from mmt_staging2.budni_lcg_gravity_test_block where ods_record=1;
select file_syspk into __file_syspk from mmt_staging2.BUDNI_LCG_Spec_H1_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.test_instance_engine_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_centre_of_gravity_location
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,310 @@
drop function if exists mmt_staging2.fn_BUDNI_NMT_ODS;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_BUDNI_NMT_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_BUDNI_NMT_ODS
Function Desc: This function populates data into ODS
File Format: BUDNI
Sheet Format: BUDNI_NMT
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_BUDNI_NMT_ODS()
***************************************************************/
delete from mmt_ods.test_instance where test_file_sheet_format='BUDNI_NMT';
delete from mmt_ods.test_instance_engine_info where test_file_sheet_format='BUDNI_NMT';
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='BUDNI_NMT';
delete from mmt_ods.budni_noise_atmospheric_conditions where test_file_sheet_format='BUDNI_NMT';
delete from mmt_ods.budni_noise_measurement_results where test_file_sheet_format='BUDNI_NMT';
delete from mmt_ods.budni_test_observations where test_file_sheet_format='BUDNI_NMT';
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,
tractor_engine_hp,
configuration,
transmission_type,
wheel_drive_type,
fip_type,
steering_type,
ballast_condition
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,
model,
tractor_HP::int tractor_engine_hp,
configuration,
transmission_type,
wheel_drive_type,
FIP_type,
steering_type,
Ballast_Condition
from mmt_staging2.BUDNI_NMT_Spec_H1_block;
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,
make,model,
type_of_track
from
mmt_staging2.BUDNI_NMT_Spec_H1_block;
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,
make,model,
rated_rpm::int,
engine_to_pto_ratio engine_to_pto_ratio_540_pto
from mmt_staging2.BUDNI_NMT_Spec_H1_block;
/*block */
insert into mmt_ods.budni_noise_atmospheric_conditions
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
noise_position,
background_noise_level_dba,
temperature_c,
pressure_kpa,
relative_humidity_pct,
wind_velocity_ms
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
column2,
column3::numeric,
column4::numeric,
column5::numeric,
column6::numeric,
column7::numeric
from mmt_staging2.BUDNI_NMT_Atmos_Cond_1_Block where ods_record=1
order by rank;
/*block */
insert into mmt_ods.budni_noise_measurement_results
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
noise_position,
gear,
travel_speed_km_per_hr,
noise_level_db_a
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
column2,
column3,
column6,
column8::numeric
from mmt_staging2.BUDNI_NMT_Meas_Results_1_Block
where ods_record=1;
insert into mmt_ods.budni_noise_atmospheric_conditions
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
noise_position,
background_noise_level_dba,
temperature_c,
pressure_kpa,
relative_humidity_pct,
wind_velocity_ms
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
column2,
column3::numeric,
column4::numeric,
column5::numeric ,
column6::numeric,
column7::numeric
from mmt_staging2.BUDNI_NMT_Atmos_Cond_2_Block where ods_record=1
order by rank;
/*block */
insert into mmt_ods.budni_noise_measurement_results
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
noise_position,
gear,
drawbar_pull_max_noise_kn,
travel_speed_km_per_hr,
noise_level_db_a
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
column2,
column3,
column4,
column6,
column8::int
from mmt_staging2.BUDNI_NMT_Meas_Results_2_Block
where ods_record=1;
insert into mmt_ods.budni_test_observations
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
sequence_number,
characteristic,
category_evaluative_or_non_evaluative,
requirements_as_per_is_12207_2008,
values_declared_by_the_applicant_d_rqmt,
as_observed,
whether_meets_the_requirements_yn
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
column3::numeric,
column4,
column5,
column6,
column7,
column8,
column9
from mmt_staging2.budni_nmt_test_obs_summary_block where ods_record=1;
select file_syspk into __file_syspk from mmt_staging2.BUDNI_NMT_Spec_H1_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.test_instance_engine_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_noise_atmospheric_conditions
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_noise_measurement_results
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_test_observations
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,270 @@
drop function if exists mmt_staging2.fn_BUDNI_PTO_ODS;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_BUDNI_PTO_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_BUDNI_PTO_ODS
Function Desc: This function populates data into ODS
File Format: BUDNI
Sheet Format: BUDNI_PTO
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_BUDNI_PTO_ODS()
***************************************************************/
delete from mmt_ods.test_instance where test_file_sheet_format='BUDNI_PTO';
delete from mmt_ods.test_instance_engine_info where test_file_sheet_format='BUDNI_PTO';
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='BUDNI_PTO';
delete from mmt_ods.budni_pto_perf_results_summary where test_file_sheet_format='BUDNI_PTO';
delete from mmt_ods.budni_test_observations where test_file_sheet_format='BUDNI_PTO';
delete from mmt_ods.budni_pto_perf_results_details where test_file_sheet_format='BUDNI_PTO';
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,
tractor_engine_hp,
configuration,
fip_type,
steering_type,
transmission_type,
wheel_drive_type
)
select
client_id,
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;
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
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model
from
mmt_staging2.BUDNI_PTO_Spec_H1_block;
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,
make,model,
rated_rpm::int,
engine_to_pto_ratio
from mmt_staging2.BUDNI_PTO_Spec_H1_block;
/*block */
insert into mmt_ods.budni_pto_perf_results_summary
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
pto_category,
pto_sub_category ,
power_kw,
speed_rpm_pto ,
speed_rpm_engine ,
fuel_consumption_ltr_per_hr,
fuel_consumption_kg_per_hr,
specific_kg_per_kwh,
specifc_energy_kwhl
)
select
client_id,
function_id,
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
order by rank;
/*block */
insert into mmt_ods.budni_pto_perf_results_details
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
ambient_type,
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_smoke_level_max_light_absorption_coef_per_mtr,
range_of_atm_conditions_temp_c,
range_of_atm_conditions_pressure_kpa,
range_of_atm_conditions_rel_humidity_pct
)
select
client_id,
function_id,
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
where ods_record=1;
/* block */
insert into mmt_ods.budni_pto_perf_results_details
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
ambient_type,
max_temp_engine_oil_c,
max_temp_coolant_water_c,
max_temp_fuel_c,
max_temp_air_intake_c,
max_temp_exhaust_gas_c,
pressure_at_max_power_intake_air_kpa,
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';
insert into mmt_ods.budni_test_observations
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
srl_no,
characteristic,
category_evaluative_or_non_evaluative,
requirements_as_per_is_12207_2008,
values_declared_by_the_applicant_d_rqmt,
as_observed,
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
where rank in (3,4) and ods_record=1
;
select file_syspk into __file_syspk from mmt_staging2.BUDNI_PTO_Spec_H1_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.test_instance_engine_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_pto_perf_results_summary
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_pto_perf_results_details
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_test_observations
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,201 @@
drop function if exists mmt_staging2.fn_BUDNI_VMT_ODS;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_BUDNI_VMT_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_BUDNI_VMT_ODS
Function Desc: This function populates data into ODS
File Format: BUDNI
Sheet Format: BUDNI_VMT
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_BUDNI_VMT_ODS()
***************************************************************/
delete from mmt_ods.test_instance where test_file_sheet_format='BUDNI_VMT';
delete from mmt_ods.test_instance_engine_info where test_file_sheet_format='BUDNI_VMT';
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='BUDNI_VMT';
delete from mmt_ods.budni_vibration_measurement where test_file_sheet_format='BUDNI_VMT';
delete from mmt_ods.budni_test_observations where test_file_sheet_format='BUDNI_VMT';
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,
tractor_engine_hp,
configuration,
transmission_type,
wheel_drive_type,
fip_type,
steering_type,
ballast_condition
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,
model,
tractor_HP::int tractor_engine_hp,
configuration,
transmission_type,
wheel_drive_type,
FIP_type,
steering_type,
Ballast_Condition
from mmt_staging2.BUDNI_VMT_Spec_H1_block;
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
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model
from
mmt_staging2.BUDNI_VMT_Spec_H1_block;
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,
make,model,
rated_rpm::int,
engine_to_pto_ratio engine_to_pto_ratio_540_pto
from mmt_staging2.BUDNI_VMT_Spec_H1_block;
insert into mmt_ods.budni_vibration_measurement
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
srl_no,
measuring_points,
vibration_at_no_load_vd_microns,
vibration_at_no_load_hd_microns,
vibration_at_load_85_pct_of_max_pto_power_vd_microns,
vibration_at_load_85_pct_of_max_pto_power_hd_microns
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
column3::numeric,
column4,
column6::numeric ,
column7::numeric ,
column8::numeric ,
column9::numeric
from mmt_staging2.BUDNI_VMT_Perf_Meas_Test_Block
where ods_record =1
order by rank;
insert into mmt_ods.budni_test_observations
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
srl_no,
characteristic,
category_evaluative_or_non_evaluative,
requirements_as_per_is_12207_2008,
values_declared_by_the_applicant_d_rqmt,
as_observed,
whether_meets_the_requirements_yn
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
column3,
column4,
column5,
column6,
column7,
column8,
column9
from mmt_staging2.BUDNI_VMT_test_obs_summary_block where ods_record=1;
select file_syspk into __file_syspk from mmt_staging2.BUDNI_VMT_Spec_H1_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.test_instance_engine_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_vibration_measurement
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.budni_test_observations
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -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;

View File

@@ -0,0 +1,754 @@
drop function if exists mmt_ods.fn_dbstd_test_ods;
CREATE OR REPLACE FUNCTION mmt_ods.fn_dbstd_test_ods()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
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_ods.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,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;
update mmt_staging2.dbstd_test_transmission_wheels_block a
set location_of_driving_wheel=(select location_of_driving_wheel from
mmt_staging2.dbstd_test_transmission_wheels_block b where location_of_driving_wheel is not null)
where location_of_driving_wheel is null;
/* 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;
select file_syspk into __file_syspk from mmt_staging2.dbstd_test_h1_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.test_instance_engine_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_drawbar_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tyre_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.drawbar_perf_results_summary
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.drawbar_perf_results
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_equipment_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_measurement_uncertainty
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info_misc
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_gear_speed_chart
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.Test_instance_wheels_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.Test_instance_fuel_lubricant_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.drawbar_perf_observations
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,302 @@
drop function if exists mmt_staging2.fn_FTDRY_SUM_ODS ;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTDRY_SUM_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_FTDRY_SUM_ODS
Function Desc: This function populates data into ODS
File Format: FTDRY
Sheet Format: FTDRY_SUM
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_FTDRY_SUM_ODS()
***************************************************************/
delete from mmt_ods.field_perf_summary where test_file_ref_no =258;
delete from mmt_ods.field_perf_summary_implement_info where test_file_ref_no =258;
delete from mmt_ods.field_perf_summary_tractor_info where test_file_ref_no =258;
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,
test_file_format,
test_file_sheet_format
)
select
client_id,
function_id,
tractor_model,
tractor_make,
tractor_engine_hp::numeric,
rated_rpm::numeric,
transmission_type,
wheel_drive_type,
fip_type,
steering_type,
tractor_weight_kg_front::numeric,
tractor_weight_kg_rear::numeric,
tractor_weight_kg_total::numeric,
file_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.ftdry_sum_trac_h1_block where tractor_model<> '0' and ods_record=1;
insert into mmt_ods.field_perf_summary_implement_info
(
client_id,
function_id,
name_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,
test_file_format,
test_file_sheet_format
)
select
client_id,
function_id,
make_of_implement,
implement_type,
implement_size,
hitch_category,
implement_weight::numeric,
soil_type,
moisture_content::numeric soil_moisture_content_pct,
bulk_density_g_cc::numeric soil_bulk_density_g_per_cc,
soil_cone_index::numeric soil_cone_index,
field_condition,
season,
file_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.ftdry_sum_implement_block where ods_record=1;
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_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_index,
pulverization_quality,
test_file_ref_no,
test_file_format,
test_file_sheet_format
)
select
client_id,
function_id,
test_condition,
test_date::date,
tractor_model,
engine_rpm_set::numeric,
pto_rpm_set::numeric,
gear_used,
nominal_speed_kmph::numeric,
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::numeric,
on_load_speed_kmph::numeric,
wheel_slippage_::numeric wheel_slippage_pct,
fuel_consumption_lit_hr::numeric fuel_consumption_lit_per_hr,
area_covered_acr_hr::numeric area_covered_acr_per_hr,
fuel_consumption_lit_acr::numeric fuel_consumption_lit_per_acr ,
case when fuel_consumption_lit_hr_2 ~ E'^\\d+$' then fuel_consumption_lit_hr_2::numeric else null end as fuel_consumption_var_lit_per_hr ,
case when area_covered_acr_hr_2 ~ E'^\\d+$' then area_covered_acr_hr_2::numeric else null end as area_covered_var_acr_per_hr ,
case when fuel_consumption_lit_acr_2 ~ E'^\\d+$' then fuel_consumption_lit_acr_2::numeric else null end as 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_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.ftdry_sum_test_condition_1_block where engine_rpm_set <> '0' and ods_record=1;
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_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_index,
pulverization_quality,
test_file_ref_no,
test_file_format,
test_file_sheet_format
)
select
client_id,
function_id,
test_condition,
test_date::date,
tractor_model,
engine_rpm_set::numeric,
pto_rpm_set::numeric,
gear_used,
nominal_speed_kmph::numeric,
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::numeric,
on_load_speed_kmph::numeric,
wheel_slippage_::numeric wheel_slippage_pct,
fuel_consumption_lit_hr::numeric fuel_consumption_lit_per_hr,
area_covered_acr_hr::numeric area_covered_acr_per_hr,
fuel_consumption_lit_acr::numeric fuel_consumption_lit_per_acr ,
case when fuel_consumption_lit_hr_2 ~ E'^\\d+$' then fuel_consumption_lit_hr_2::numeric else null end as fuel_consumption_var_lit_per_hr ,
case when area_covered_acr_hr_2 ~ E'^\\d+$' then area_covered_acr_hr_2::numeric else null end as area_covered_var_acr_per_hr ,
case when fuel_consumption_lit_acr_2 ~ E'^\\d+$' then fuel_consumption_lit_acr_2::numeric else null end as 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_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.ftdry_sum_test_condition_2_block where engine_rpm_set <> '0' and ods_record=1;
select file_syspk into __file_syspk from mmt_staging2.ftdry_sum_trac_h1_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.field_perf_summary
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.field_perf_summary_implement_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.field_perf_summary_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,299 @@
drop function if exists mmt_staging2.fn_FTDRY_TRS_ODS ;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTDRY_TRS_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_FTDRY_TRS_ODS
Function Desc: This function populates data into ODS
File Format: FTDRY
Sheet Format: FTDRY_TRS
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_FTDRY_TRS_ODS()
***************************************************************/
delete from mmt_ods.test_instance where test_file_ref_no =258;
delete from mmt_ods.test_instance_engine_info where test_file_ref_no =258;
delete from mmt_ods.test_instance_implement_info where test_file_ref_no =258;
delete from mmt_ods.test_instance_tractor_info where test_file_ref_no =258;
delete from mmt_ods.test_instance_trailer_info where test_file_ref_no =258;
delete from mmt_ods.test_instance_tyre_info where test_file_ref_no =258;
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,
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,
test_file_ref_no,
test_file_format,
test_file_sheet_format
)
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,
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,
file_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.ftdry_trs_h1_block where ods_record=1;
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,
test_file_format,
test_file_sheet_format
)
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_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.ftdry_trs_spec_block where tractor_model is not null and ods_record=1;
insert into mmt_ods.test_instance_tyre_info
(
client_id,
function_id,
tractor_make,
tractor_model,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tyre_type,
tyre_make,
tyre_size,
tyre_pressure_psi
)
select
client_id,
function_id,
tractor_make,
tractor_model,
file_syspk,
file_format,
sheet_mnemonic,
'front',
front_tyre_make tyre_make,
front_tyre_size tyre_size,
front_tyre_pressure_psi::int tyre_pressure_psi
from mmt_staging2.ftdry_trs_spec_block where front_tyre_make is not null and ods_record=1;
insert into mmt_ods.test_instance_tyre_info
(
client_id,
function_id,
tractor_make,
tractor_model,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tyre_type,
tyre_make,
tyre_size,
tyre_pressure_psi
)
select
client_id,
function_id,
tractor_make,
tractor_model,
file_syspk,
file_format,
sheet_mnemonic,
'rear',
front_tyre_make tyre_make,
front_tyre_size tyre_size,
front_tyre_pressure_psi::int tyre_pressure_psi
from mmt_staging2.ftdry_trs_spec_block where rear_tyre_make is not null and ods_record=1;
insert into mmt_ods.test_instance_engine_info
(
client_id,
function_id,
low_idle_observed ,
high_idle_observed ,
rated_rpm ,
engine_to_pto_ratio_540_pto,
engine_to_pto_ratio_540e_pto,
tractor_model,
tractor_make,
test_file_ref_no,
test_file_format,
test_file_sheet_format
)
select
client_id,
function_id,
low_idle::int low_idle_observed ,
high_idle::int high_idle_observed ,
rated_rpm::int,
engine_to_pto_ratio_540_pto,
engine_to_pto_ratio_540e_pto,
tractor_model,
tractor_make,
file_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.ftdry_trs_engine_rpm_block
where tractor_model is not null and ods_record=1;
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_mm ,
mast_height_for_mounted_implement_mm,
test_file_ref_no,
test_file_format,
test_file_sheet_format
)
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_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.ftdry_trs_implement_block where name_of_implement is not null and ods_record=1;
update mmt_ods.test_instance a
set report_template_no=b.report_template_no,
report_template_rev_no=b.report_template_rev_no,
report_template_rev_date =b.report_template_rev_date
from mmt_staging2.ftdry_trs_implement_block b where name_of_implement is not null and ods_record=1
and a.test_file_ref_no=b.file_syspk;
select file_syspk into __file_syspk from mmt_staging2.FTDRY_TRS_H1_Block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.test_instance_engine_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tyre_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_implement_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,295 @@
drop function if exists mmt_staging2.fn_FTHLG_SUM_ODS ;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTHLG_SUM_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_FTHLG_SUM_ODS
Function Desc: This function populates data into ODS
File Format: FTHLG
Sheet Format: FTHLG_SUM
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_FTHLG_SUM_ODS();
***************************************************************/
delete from mmt_ods.field_perf_summary where test_file_ref_no =259;
delete from mmt_ods.field_perf_summary_implement_info where test_file_ref_no =259;
delete from mmt_ods.field_perf_summary_tractor_info where test_file_ref_no =259;
delete from mmt_ods.field_perf_summary_trailer_info where test_file_ref_no =259;
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,
test_file_format,
test_file_sheet_format
)
select
client_id,
function_id,
tractor_model,
tractor_make ,
tractor_engine_hp::numeric,
rated_rpm::numeric,
transmission_type,
wheel_drive_type,
fip_type,
steering_type,
tractor_weight_kg_front::numeric tractor_weight_front_kg,
tractor_weight_kg_rear::numeric tractor_weight_rear_kg,
tractor_weight_kg_total::numeric tractor_weight_total_kg,
file_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.fthlg_sum_trac_h1_block where tractor_model<> '0' and ods_record=1;
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_ht_mm,
trailer_hitch_height_above_ground_level_mm,
gradient_slope_1_degree,
gradient_slope_2_degree,
tractor_hitch_type,
test_file_ref_no,
test_file_format,
test_file_sheet_format
)
select
client_id,
function_id,
Trailer_Type,
Tire_size_and_inflation_pressure_psi,
No_Of_Axle::numeric ,
No_Of_Wheels::numeric,
Trailer_Gross_Weight_Kg::numeric,
Tractor_Rear_Wheel_Center_to_Hitch_Point_Center_Distance_mm::numeric,
Tractor_Hitch_Height_from_Ground_mm::numeric,
Trailer_hitch_Height_above_ground_level_mm::numeric,
Gradient_Slope_1_Degree::numeric,
Gradient_Slope_2_degree::numeric,
Tractor_Hitch_Type,
file_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.FTHLG_SUM_Trail_Type_Block where ods_record=1;
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,
test_file_format,
test_file_sheet_format
)
select
client_id,
function_id,
Test_Condition,
Test_Date::date,
Tractor_Model,
Fuel_consumption_Ltr_hr::numeric fuel_consumption_lit_per_hr ,
Mileage_Km_Ltr ::numeric mileage_km_per_ltr ,
Average_speed_of_travel_kmph::numeric avg_speed_of_travel_kmph ,
Total_distance_travelled_km::numeric 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::numeric else null end as fuel_consumption_var_lit_per_hr ,
case when Mileage_Km_Ltr_2 ~ E'^\\d+$' then Mileage_Km_Ltr_2::numeric else null end as mileage_var_km_per_ltr,
case when fuel_consumption_lit_hr_3 ~ E'^\\d+$' then fuel_consumption_lit_hr_3::numeric else null end as fuel_consumption_var_pct_lit_per_hr ,
case when Mileage_Km_Ltr_3 ~ E'^\\d+$' then Mileage_Km_Ltr_3::numeric 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_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.fthlg_sum_test_condition_1_block
where test_date::date =date '30-Nov-2020' and test_date <> '0' and Gear_used_on_Straight_Road not in ('0','0.000') and ods_record=1;
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,
test_file_format,
test_file_sheet_format
)
select
client_id,
function_id,
Test_Condition,
Test_Date::date,
Tractor_Model,
Fuel_consumption_Ltr_hr::numeric fuel_consumption_lit_per_hr ,
Mileage_Km_Ltr ::numeric mileage_km_per_ltr ,
Average_speed_of_travel_kmph::numeric avg_speed_of_travel_kmph ,
Total_distance_travelled_km::numeric 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::numeric else null end as fuel_consumption_var_lit_per_hr ,
case when Mileage_Km_Ltr_2 ~ E'^\\d+$' then Mileage_Km_Ltr_2::numeric else null end as mileage_var_km_per_ltr,
case when fuel_consumption_lit_hr_3 ~ E'^\\d+$' then fuel_consumption_lit_hr_3::numeric else null end as fuel_consumption_var_pct_lit_per_hr ,
case when Mileage_Km_Ltr_3 ~ E'^\\d+$' then Mileage_Km_Ltr_3::numeric 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_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.fthlg_sum_test_condition_2_block
where test_date::date =date '30-Nov-2020' and test_date <> '0' and Gear_used_on_Straight_Road not in ('0','0.000') and ods_record=1;
select file_syspk into __file_syspk from mmt_staging2.fthlg_sum_trac_h1_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.field_perf_summary
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.field_perf_summary_implement_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.field_perf_summary_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.field_perf_summary_trailer_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,324 @@
drop function if exists mmt_staging2.fn_FTHLG_TRS_ODS ;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTHLG_TRS_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_FTHLG_TRS_ODS
Function Desc: This function populates data into ODS
File Format: FTHLG
Sheet Format: FTHLG_TRS
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_FTHLG_TRS_ODS()
***************************************************************/
delete from mmt_ods.test_instance where test_file_ref_no =259;
delete from mmt_ods.test_instance_engine_info where test_file_ref_no =259;
delete from mmt_ods.test_instance_implement_info where test_file_ref_no =259;
delete from mmt_ods.test_instance_tractor_info where test_file_ref_no =259;
delete from mmt_ods.test_instance_trailer_info where test_file_ref_no =259;
delete from mmt_ods.test_instance_tyre_info where test_file_ref_no =259;
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,
test_file_format,
test_file_sheet_format
)
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,
file_format,
sheet_mnemonic
from mmt_staging2.FTHLG_TRS_H1_Block where ods_record=1;
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,
test_file_format,
test_file_sheet_format
)
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,
file_format,
sheet_mnemonic
from mmt_staging2.fthlg_trs_spec_block where tractor_model is not null and ods_record=1;
insert into mmt_ods.test_instance_tyre_info
(
client_id,
function_id,
tractor_make,
tractor_model,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tyre_type,
tyre_make,
tyre_size,
tyre_pressure_psi
)
select
client_id,
function_id,
tractor_make,
tractor_model,
file_syspk,
file_format,
sheet_mnemonic,
'front',
front_tyre_make tyre_make,
front_tyre_size tyre_size,
front_tyre_pressure_psi::int tyre_pressure_psi
from mmt_staging2.fthlg_trs_spec_block where front_tyre_make is not null and ods_record=1;
insert into mmt_ods.test_instance_tyre_info
(
client_id,
function_id,
tractor_make,
tractor_model,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tyre_type,
tyre_make,
tyre_size,
tyre_pressure_psi
)
select
client_id,
function_id,
tractor_make,
tractor_model,
file_syspk,
file_format,
sheet_mnemonic,
'rear',
front_tyre_make tyre_make,
front_tyre_size tyre_size,
front_tyre_pressure_psi::int tyre_pressure_psi
from mmt_staging2.fthlg_trs_spec_block where rear_tyre_make is not null and ods_record=1;
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,
test_file_format,
test_file_sheet_format
)
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,
file_format,
sheet_mnemonic
from mmt_staging2.fthlg_trs_engine_rpm_block where tractor_model is not null and ods_record=1;
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,
test_file_format,
test_file_sheet_format
)
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,
file_format,
sheet_mnemonic
from mmt_staging2.fthlg_trs_trailer_block where type_of_trailer is not null and ods_record=1;
update mmt_ods.test_instance a
set report_template_no=b.report_template_no,
report_template_rev_no=b.report_template_rev_no,
report_template_rev_date =b.report_template_rev_date
from mmt_staging2.fthlg_trs_trailer_block b where type_of_trailer is not null and ods_record=1
and a.test_file_ref_no=b.file_syspk;
select file_syspk into __file_syspk from mmt_staging2.FTHLG_TRS_H1_Block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.test_instance_engine_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tyre_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_implement_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_trailer_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,251 @@
drop function if exists mmt_staging2.fn_FTWET_SUM_ODS ;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTWET_SUM_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_FTWET_SUM_ODS
Function Desc: This function populates data into ODS
File Format: FTWET
Sheet Format: FTWET_SUM
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_FTWET_SUM_ODS()
***************************************************************/
delete from field_perf_summary where test_file_ref_no =260;
delete from mmt_ods.field_perf_summary_implement_info where test_file_ref_no =260;
delete from mmt_ods.field_perf_summary_tractor_info where test_file_ref_no =260;
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,
test_file_format,
test_file_sheet_format
)
select
client_id,
function_id,
tractor_model,
tractor_make,
tractor_engine_hp::numeric,
rated_rpm::numeric,
transmission_type,
wheel_drive_type,
fip_type,
steering_type,
tractor_weight_kg_front::numeric,
tractor_weight_kg_rear::numeric,
tractor_weight_kg_total::numeric,
file_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.ftwet_sum_trac_h1_block where tractor_model<> '0' and ods_record=1;
insert into mmt_ods.field_perf_summary_implement_info
(
client_id,
function_id,
name_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,
test_file_format,
test_file_sheet_format
)
select
client_id,
function_id,
make_of_implement,
implement_type,
implement_size,
hitch_category,
implement_weight::numeric,
soil_type,
moisture_content::numeric soil_moisture_content_pct,
bulk_density_g_cc::numeric soil_bulk_density_g_per_cc,
soil_cone_index::numeric soil_cone_index,
field_condition,
season,
file_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.ftwet_sum_implement_block where ods_record=1;
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,
no_of_angles_on_cage_wheel,
test_file_ref_no,
test_file_format,
test_file_sheet_format
)
select
client_id,
function_id,
Type_of_Cage_Wheel,
Cage_Wheel_Width_mm::numeric,
Cage_wheel_Weight::numeric,
Cage_Wheel_inner_Outer_Ring_Dia_mm::numeric cage_wheel_inner_and_outer_ring_dia_mm,
Cage_Wheel_Center_Ring_Dia_mm::numeric,
No_of_angles_on_cage_wheel::numeric,
file_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.FTWET_SUM_Cage_Wheel_Block where ods_record=1;
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_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,
test_file_format,
test_file_sheet_format
)
select
client_id,
function_id,
Test_Condition,
Test_Date::date,
Tractor_Model,
Engine_RPM_set::numeric,
PTO_RPM_set::numeric,
Gear_Used,
Nominal_Speed_KMPH::numeric,
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::numeric,
Avg_Depth_of_cut_cm depth_of_cut_cm ,
Fuel_consumption_lit_hr::numeric fuel_consumption_lit_per_hr,
Area_covered_acr_hr::numeric area_covered_acr_per_hr,
Fuel_consumption_lit_Acr::numeric fuel_consumption_lit_per_acr,
case when fuel_consumption_lit_hr_2 ~ E'^\\d+$' then fuel_consumption_lit_hr_2::numeric else null end as fuel_consumption_var_lit_per_hr ,
case when area_covered_acr_hr_2 ~ E'^\\d+$' then area_covered_acr_hr_2::numeric else null end as area_covered_var_acr_per_hr ,
case when fuel_consumption_lit_acr_2 ~ E'^\\d+$' then fuel_consumption_lit_acr_2::numeric else null end as 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_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.FTWET_SUM_Test_Condition_Block where test_date <> 'DD/MM/YY' and engine_rpm_set <> '0' and ods_record=1;
select file_syspk into __file_syspk from mmt_staging2.ftwet_sum_trac_h1_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.field_perf_summary
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.field_perf_summary_implement_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.field_perf_summary_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.field_perf_summary_trailer_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.field_perf_summary_implement_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,321 @@
drop function if exists mmt_staging2.fn_FTWET_TRS_ODS ;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTWET_TRS_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
/************************************************************
Function Name:fn_FTWET_TRS_ODS
Function Desc: This function populates data into ODS
File Format: FTWET
Sheet Format: FTWET_TRS
Creation Date:
Updation Date:
Author: compegence team
Function Call: select mmt_staging2.fn_FTWET_TRS_ODS()
***************************************************************/
delete from mmt_ods.test_instance where test_file_ref_no =260;
delete from mmt_ods.test_instance_engine_info where test_file_ref_no =260;
delete from mmt_ods.test_instance_implement_info where test_file_ref_no =260;
delete from mmt_ods.test_instance_tractor_info where test_file_ref_no =260;
delete from mmt_ods.test_instance_trailer_info where test_file_ref_no =260;
delete from mmt_ods.test_instance_tyre_info where test_file_ref_no =260;
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,
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,
test_file_ref_no,
test_file_format,
test_file_sheet_format
)
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,
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,
file_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.ftwet_trs_h1_block where ods_record=1;
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,
test_file_format,
test_file_sheet_format
)
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_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.ftwet_trs_spec_block where tractor_model is not null and ods_record=1;
insert into mmt_ods.test_instance_tyre_info
(
client_id,
function_id,
tractor_make,
tractor_model,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tyre_type,
tyre_make,
tyre_size,
tyre_pressure_psi
)
select
client_id,
function_id,
tractor_make,
tractor_model,
file_syspk,
file_format,
sheet_mnemonic,
'front',
front_tyre_make tyre_make,
front_tyre_size tyre_size,
front_tyre_pressure_psi::int tyre_pressure_psi
from mmt_staging2.ftwet_trs_spec_block where front_tyre_make is not null and ods_record=1;
insert into mmt_ods.test_instance_tyre_info
(
client_id,
function_id,
tractor_make,
tractor_model,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tyre_type,
tyre_make,
tyre_size,
tyre_pressure_psi
)
select
client_id,
function_id,
tractor_make,
tractor_model,
file_syspk,
file_format,
sheet_mnemonic,
'rear',
front_tyre_make tyre_make,
front_tyre_size tyre_size,
front_tyre_pressure_psi::int tyre_pressure_psi
from mmt_staging2.ftwet_trs_spec_block where rear_tyre_make is not null and ods_record=1;
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,
test_file_ref_no,
test_file_format,
test_file_sheet_format
)
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,
file_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.ftwet_trs_engine_rpm_block where tractor_model is not null and ods_record=1;
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_mm,
mast_height_for_mounted_implement_mm,
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,
test_file_format,
test_file_sheet_format
)
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_syspk,
file_format,
sheet_mnemonic
from mmt_staging2.ftwet_trs_implement_block where name_of_implement is not null and ods_record=1;
update mmt_ods.test_instance a
set report_template_no=b.report_template_no,
report_template_rev_no=b.report_template_rev_no,
report_template_rev_date =b.report_template_rev_date
from mmt_staging2.ftwet_trs_implement_block b where name_of_implement is not null
and a.test_file_ref_no=b.file_syspk;
select file_syspk into __file_syspk from mmt_staging2.FTWET_TRS_H1_Block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.test_instance_engine_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_tyre_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_implement_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_trailer_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,171 @@
drop function if exists mmt_staging2.fn_PTO_GVG_ODS;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_PTO_GVG_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
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);
select file_syspk into __file_syspk from mmt_staging2.PTOBST_RPT_tractor_specs_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.PTO_Perf_Governing_Graph
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,45 @@
drop function if exists mmt_staging2.fn_PTO_MPM_ODS;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_PTO_MPM_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
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 ;
select file_syspk into __file_syspk from mmt_staging2.PTOBST_RPT_tractor_specs_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.PTO_Multipoint_Mapping
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,125 @@
drop function if exists mmt_staging2.fn_PTO_PHA_ODS;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_PTO_PHA_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
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;
select file_syspk into __file_syspk from mmt_staging2.PTOBST_RPT_tractor_specs_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.PTO_Key_Perf_Parameters
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.PTO_Perf_Results
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.pto_engine_oil_consumption
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,196 @@
drop function if exists mmt_staging2.fn_PTO_PNA_ODS;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_PTO_PNA_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
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 ;
select file_syspk into __file_syspk from mmt_staging2.PTOBST_RPT_tractor_specs_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.PTO_Key_Perf_Parameters
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.PTO_Perf_Results
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.pto_smoke_test
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

View File

@@ -0,0 +1,268 @@
drop function if exists mmt_staging2.fn_PTO_report_ODS;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_PTO_report_ODS()
RETURNS void AS $$
declare __test_instance_id int;
declare __file_syspk int;
begin
SET search_path TO mmt_staging2;
/*************************************************************
Function Name:fn_PTO_REPORT_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_report_ODS()
***************************************************************/
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,
tractor_engine_hp,
configuration,
fip_type,
steering_type,
transmission_type,
wheel_drive_type
)
select
client_id,
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.PTOBST_RPT_tractor_specs_block;
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
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model
from
mmt_staging2.PTOBST_RPT_tractor_specs_block;
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,
make,model,rated_rpm::int,engine_to_pto_ratio
from mmt_staging2.PTOBST_RPT_tractor_specs_block;
/*block */
insert into mmt_ods.PTO_Perf_Report_Summary
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
pto_category ,
pto_sub_category ,
power_kw,
speed_rpm_pto ,
speed_rpm_engine ,
fuel_consumption_ltr_per_hr ,
fuel_consumption_kg_per_h ,
sfc_kg_per_kwh ,
specifc_energy_kwh_per_ltr
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
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.PTO_Perf_Report_Details
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
ambient_type,
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,
pct_backup_torque,
pct_smoke_level_max_light_absorption_coef_per_mtr,
range_of_atm_conditions_temp_c,
range_of_atm_conditions_pressure_kpa,
range_of_atm_conditions_rel_humidity_pct
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,model,
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.PTO_Perf_Report_Details
(
client_id,
function_id,
test_file_ref_no,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
ambient_type,
max_temp_engine_oil_c,
max_temp_coolant_water_c,
max_temp_fuel_c,
max_temp_air_intake_c,
max_temp_exhaust_gas_c,
pressure_at_max_power_intake_air_kpa,
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,
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';
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,
test_file_format,
test_file_sheet_format,
tractor_make,
tractor_model,
srl_no,
characteristic,
category_evaluative_or_non_evaluative,
requirements_as_per_is_12207_2008,
values_declared_by_the_applicant_d_rqmt,
as_observed,
whether_meets_the_requirements_yn
)
select
client_id,
function_id,
file_syspk,
file_format,
sheet_mnemonic,
make,
model,
c3::text,
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;
select file_syspk into __file_syspk from mmt_staging2.PTOBST_RPT_tractor_specs_block;
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
update mmt_ods.test_instance_tractor_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.test_instance_engine_info
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.PTO_Perf_Report_Summary
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.PTO_Perf_Test_Observations
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
update mmt_ods.PTO_Perf_Report_Details
set test_instance_id=__test_instance_id
where test_file_ref_no=__file_syspk;
end
$$ LANGUAGE plpgsql;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,425 @@
/*
ALTER TABLE fw_m_role
ADD CONSTRAINT fk_fw_m_role_client_function_id
FOREIGN KEY ( client_id, function_id )
REFERENCES fw_m_function(client_id, function_id);
*/
CREATE UNIQUE INDEX CONCURRENTLY test_master_id
ON test_master (client_id, function_id, test_name );
ALTER TABLE test_master
ADD CONSTRAINT unique_test_master_id
UNIQUE USING INDEX test_master_id;
CREATE UNIQUE INDEX CONCURRENTLY test_lab_location_id
ON test_lab_location_master (client_id, function_id, location_name);
ALTER TABLE test_lab_location_master
ADD CONSTRAINT unique_test_lab_location_id
UNIQUE USING INDEX test_lab_location_id;
CREATE UNIQUE INDEX CONCURRENTLY test_instance_id
ON test_instance (client_id, function_id, Test_master_Id, Test_File_Ref_No );
ALTER TABLE test_instance
ADD CONSTRAINT unique_test_instance_id
UNIQUE USING INDEX test_instance_id;
CREATE UNIQUE INDEX CONCURRENTLY Test_instance_tractor_info_id
ON Test_instance_tractor_info (client_id, function_id, Test_instance_Id, Tractor_Model );
ALTER TABLE Test_instance_tractor_info
ADD CONSTRAINT unique_Test_instance_tractor_info_id
UNIQUE USING INDEX Test_instance_tractor_info_id;
CREATE UNIQUE INDEX CONCURRENTLY Test_instance_implement_info_id
ON Test_instance_implement_info (client_id, function_id, Test_instance_Id, Name_of_Implement );
ALTER TABLE Test_instance_implement_info
ADD CONSTRAINT unique_Test_instance_implement_info_id
UNIQUE USING INDEX Test_instance_implement_info_id;
CREATE UNIQUE INDEX CONCURRENTLY Test_instance_trailer_info_id
ON Test_instance_trailer_info (client_id, function_id, Test_instance_Id, Type_Of_Trailer, No_Of_Axle );
ALTER TABLE Test_instance_trailer_info
ADD CONSTRAINT unique_Test_instance_trailer_info_id
UNIQUE USING INDEX Test_instance_trailer_info_id;
CREATE UNIQUE INDEX CONCURRENTLY Test_instance_engine_info_id
ON Test_instance_engine_info (client_id, function_id, Test_instance_Id, Test_instance_Tractor_Id );
ALTER TABLE Test_instance_engine_info
ADD CONSTRAINT unique_Test_instance_engine_info_id
UNIQUE USING INDEX Test_instance_engine_info_id;
CREATE UNIQUE INDEX CONCURRENTLY test_instance_tyre_info_id
ON test_instance_tyre_info (client_id, function_id, Test_instance_Id, Test_instance_Tractor_Id, Tyre_Type );
ALTER TABLE test_instance_tyre_info
ADD CONSTRAINT unique_test_instance_tyre_info_id
UNIQUE USING INDEX Test_instance_tyre_info_id;
CREATE UNIQUE INDEX CONCURRENTLY test_instance_gear_speed_chart_id
ON test_instance_gear_speed_chart (client_id, function_id, Test_instance_Id, Tyre_condition,Forward_Reverse,Gear );
ALTER TABLE test_instance_gear_speed_chart
ADD CONSTRAINT unique_test_instance_gear_speed_chart_id
UNIQUE USING INDEX test_instance_gear_speed_chart_id;
CREATE UNIQUE INDEX CONCURRENTLY test_instance_tractor_info_misc_id
ON test_instance_tractor_info_misc (client_id, function_id, Test_instance_Id, Test_instance_Tractor_Id );
ALTER TABLE test_instance_tractor_info_misc
ADD CONSTRAINT unique_test_instance_tractor_info_misc_id
UNIQUE USING INDEX test_instance_tractor_info_misc_id;
CREATE UNIQUE INDEX CONCURRENTLY test_instance_Wheels_info_id
ON test_instance_Wheels_info (client_id, function_id, Test_instance_Id, steered_Driving_wheel );
ALTER TABLE test_instance_Wheels_info
ADD CONSTRAINT unique_test_instance_Wheels_info_id
UNIQUE USING INDEX test_instance_Wheels_info_id;
CREATE UNIQUE INDEX CONCURRENTLY test_instance_fuel_lubricant_info_id
ON test_instance_fuel_lubricant_info (client_id, function_id, Test_instance_Id, fuel_lubricant_unit );
ALTER TABLE test_instance_fuel_lubricant_info
ADD CONSTRAINT unique_test_instance_fuel_lubricant_info_id
UNIQUE USING INDEX test_instance_fuel_lubricant_info_id;
CREATE UNIQUE INDEX CONCURRENTLY test_instance_equipment_info_id
ON test_instance_equipment_info (client_id, function_id, Test_instance_Id, Srl_No );
ALTER TABLE test_instance_equipment_info
ADD CONSTRAINT unique_test_instance_equipment_info_id
UNIQUE USING INDEX test_instance_equipment_info_id;
CREATE UNIQUE INDEX CONCURRENTLY test_instance_measurement_uncertainty_id
ON test_instance_measurement_uncertainty (client_id, function_id, Test_instance_Id );
ALTER TABLE test_instance_measurement_uncertainty
ADD CONSTRAINT unique_test_instance_measurement_uncertainty_id
UNIQUE USING INDEX test_instance_measurement_uncertainty_id;
CREATE UNIQUE INDEX CONCURRENTLY test_instance_atmosp_info_id
ON test_instance_atmosp_info (client_id, function_id, Test_instance_Id );
ALTER TABLE test_instance_atmosp_info
ADD CONSTRAINT unique_test_instance_atmosp_info_id
UNIQUE USING INDEX test_instance_atmosp_info_id;
CREATE UNIQUE INDEX CONCURRENTLY test_instance_drawbar_info_id
ON test_instance_drawbar_info (client_id, function_id, Test_instance_Id, Drawbar_type_name);
ALTER TABLE test_instance_drawbar_info
ADD CONSTRAINT unique_test_instance_drawbar_info_id
UNIQUE USING INDEX test_instance_drawbar_info_id;
CREATE UNIQUE INDEX CONCURRENTLY Field_Perf_Summary_tractor_info_id
ON Field_Perf_Summary_tractor_info (client_id, function_id, Test_instance_Id , Test_instance_Tractor_Id);
ALTER TABLE Field_Perf_Summary_tractor_info
ADD CONSTRAINT unique_Field_Perf_Summary_tractor_info_id
UNIQUE USING INDEX Field_Perf_Summary_tractor_info_id;
CREATE UNIQUE INDEX CONCURRENTLY Field_Perf_Summary_implement_info_id
ON Field_Perf_Summary_implement_info (client_id, function_id, Test_instance_Id, Name_of_Implement);
ALTER TABLE Field_Perf_Summary_implement_info
ADD CONSTRAINT unique_Field_Perf_Summary_implement_info_id
UNIQUE USING INDEX Field_Perf_Summary_implement_info_id;
CREATE UNIQUE INDEX CONCURRENTLY Field_Perf_Summary_Soil_info_id
ON Field_Perf_Summary_Soil_info (client_id, function_id, Test_instance_Id );
ALTER TABLE Field_Perf_Summary_Soil_info
ADD CONSTRAINT unique_Field_Perf_Summary_Soil_info_id
UNIQUE USING INDEX Field_Perf_Summary_Soil_info_id;
CREATE UNIQUE INDEX CONCURRENTLY Field_Perf_Summary_trailer_info_id
ON Field_Perf_Summary_trailer_info (client_id, function_id, Test_instance_Id, Trailer_type);
ALTER TABLE Field_Perf_Summary_trailer_info
ADD CONSTRAINT unique_Field_Perf_Summary_trailer_info_id
UNIQUE USING INDEX Field_Perf_Summary_trailer_info_id;
CREATE UNIQUE INDEX CONCURRENTLY Field_Perf_summary_id
ON Field_Perf_summary (client_id, function_id, Test_instance_Id, Test_instance_Tractor_Id, Test_iteration_number );
ALTER TABLE Field_Perf_summary
ADD CONSTRAINT unique_Field_Perf_summary_id
UNIQUE USING INDEX Field_Perf_summary_id;
++++++++++++++++++++++++++++++++++++++++++++++++++++++
CREATE UNIQUE INDEX CONCURRENTLY Drawbar_Perf_results_id
ON Drawbar_Perf_results (client_id, function_id, Test_instance_Id, Gear_Number_and_Range );
ALTER TABLE Drawbar_Perf_results
ADD CONSTRAINT unique_Drawbar_Perf_results_id
UNIQUE USING INDEX Drawbar_Perf_results_id;
CREATE UNIQUE INDEX CONCURRENTLY Drawbar_Perf_results_summary_id
ON Drawbar_Perf_results_summary (client_id, function_id, Test_instance_Id, Gear_Number_and_Range );
ALTER TABLE Drawbar_Perf_results_summary
ADD CONSTRAINT unique_Drawbar_Perf_results_summary_id
UNIQUE USING INDEX Drawbar_Perf_results_summary_id;
CREATE UNIQUE INDEX CONCURRENTLY Drawbar_Perf_Noise_Measurement_Results_id
ON Drawbar_Perf_Noise_Measurement_Results (client_id, function_id, Test_instance_Id, Test_condition,test_mode,Gear,Speed_rpm );
ALTER TABLE Drawbar_Perf_Noise_Measurement_Results
ADD CONSTRAINT unique_Drawbar_Perf_Noise_Measurement_Results_id
UNIQUE USING INDEX Drawbar_Perf_Noise_Measurement_Results_id;
CREATE UNIQUE INDEX CONCURRENTLY Drawbar_Perf_observations_id
ON Drawbar_Perf_observations (client_id, function_id, Test_instance_Id, Srl_No);
ALTER TABLE Drawbar_Perf_observations_summary
ADD CONSTRAINT unique_Drawbar_Perf_observations_id
UNIQUE USING INDEX Drawbar_Perf_observations_id;
CREATE UNIQUE INDEX CONCURRENTLY PTO_Perf_results_id
ON PTO_Perf_results (client_id, function_id, Test_instance_Id, PTO_Test_Type, Speed_Engine_rpm );
ALTER TABLE PTO_Perf_results
ADD CONSTRAINT unique_PTO_Perf_results_id
UNIQUE USING INDEX PTO_Perf_results_id;
CREATE UNIQUE INDEX CONCURRENTLY PTO_Perf_Report_Summary_id
ON PTO_Perf_Report_Summary (client_id, function_id, Test_instance_Id, PTO_Category, PTO_Sub_Category );
ALTER TABLE PTO_Perf_Report_Summary
ADD CONSTRAINT unique_PTO_Perf_Report_Summary_id
UNIQUE USING INDEX PTO_Perf_Report_Summary_id;
CREATE UNIQUE INDEX CONCURRENTLY PTO_Perf_Report_Details_id
ON PTO_Perf_Report_Details (client_id, function_id, Test_instance_Id, Ambient_type );
ALTER TABLE PTO_Perf_Report_Details
ADD CONSTRAINT unique_PTO_Perf_Report_Details_id
UNIQUE USING INDEX PTO_Perf_Report_Details_id;
CREATE UNIQUE INDEX CONCURRENTLY PTO_Perf_test_observations_id
ON PTO_Perf_test_observations (client_id, function_id, Test_instance_Id, Srl_No );
ALTER TABLE PTO_Perf_test_observations
ADD CONSTRAINT unique_PTO_Perf_test_observations_id
UNIQUE USING INDEX PTO_Perf_test_observations_id;
CREATE UNIQUE INDEX CONCURRENTLY PTO_Key_Perf_Parameters_id
ON PTO_Key_Perf_Parameters (client_id, function_id, Test_instance_Id, Test_Condtion );
ALTER TABLE PTO_Key_Perf_Parameters
ADD CONSTRAINT unique_PTO_Key_Perf_Parameters_id
UNIQUE USING INDEX PTO_Key_Perf_Parameters_id;
CREATE UNIQUE INDEX CONCURRENTLY PTO_smoke_Test_id
ON PTO_smoke_Test (client_id, function_id, Test_instance_Id, Engine_speed_rpm );
ALTER TABLE PTO_smoke_Test
ADD CONSTRAINT unique_PTO_smoke_Test_id
UNIQUE USING INDEX PTO_smoke_Test_id;
CREATE UNIQUE INDEX CONCURRENTLY PTO_Engine_oil_consumption_id
ON PTO_Engine_oil_consumption (client_id, function_id, Test_instance_Id, Srl_No );
ALTER TABLE PTO_Engine_oil_consumption
ADD CONSTRAINT unique_PTO_Engine_oil_consumption_id
UNIQUE USING INDEX PTO_Engine_oil_consumption_id;
CREATE UNIQUE INDEX CONCURRENTLY PTO_Multipoint_mapping_id
ON PTO_Multipoint_mapping (client_id, function_id, Test_instance_Id, Test_condition,Engine_speed_rpm,Engine_load_pct );
ALTER TABLE PTO_Multipoint_mapping
ADD CONSTRAINT unique_PTO_Multipoint_mapping_id
UNIQUE USING INDEX PTO_Multipoint_mapping_id;
CREATE UNIQUE INDEX CONCURRENTLY PTO_Perf_Governing_Graph_id
ON PTO_Perf_Governing_Graph (client_id, function_id, Test_instance_Id, Test_condition,Engine_speed_rpm );
ALTER TABLE PTO_Perf_Governing_Graph
ADD CONSTRAINT unique_PTO_Perf_Governing_Graph_id
UNIQUE USING INDEX PTO_Perf_Governing_Graph_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_PTO_Perf_Results_summary_id
ON Budni_PTO_Perf_Results_summary (client_id, function_id, Test_instance_Id, PTO_Category,PTO_Sub_Category );
ALTER TABLE Budni_PTO_Perf_Results_summary
ADD CONSTRAINT unique_Budni_PTO_Perf_Results_summary_id
UNIQUE USING INDEX Budni_PTO_Perf_Results_summary_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_PTO_Perf_Results_Details_id
ON Budni_PTO_Perf_Results_Details (client_id, function_id, Test_instance_Id, Ambient_type );
ALTER TABLE Budni_PTO_Perf_Results_Details
ADD CONSTRAINT unique_Budni_PTO_Perf_Results_Details_id
UNIQUE USING INDEX Budni_PTO_Perf_Results_Details_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_Drawbar_Perf_Results_id
ON Budni_Drawbar_Perf_Results (client_id, function_id, Test_instance_Id, Test_Condtion, Gear_Used );
ALTER TABLE Budni_Drawbar_Perf_Results
ADD CONSTRAINT unique_Budni_Budni_Drawbar_Perf_Results_id
UNIQUE USING INDEX Budni_Drawbar_Perf_Results_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_Hydraulic_Power_test_Results_id
ON Budni_Hydraulic_Power_test_Results (client_id, function_id, Test_instance_Id );
ALTER TABLE Budni_Hydraulic_Power_test_Results
ADD CONSTRAINT unique_Budni_Hydraulic_Power_test_Results_id
UNIQUE USING INDEX Budni_Hydraulic_Power_test_Results_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_Hydraulic_Lifting_Capacity_test_Results_id
ON Budni_Hydraulic_Lifting_Capacity_test_Results (client_id, function_id, Test_instance_Id , Test_condition);
ALTER TABLE Budni_Hydraulic_Lifting_Capacity_test_Results
ADD CONSTRAINT unique_Budni_Hydraulic_Lifting_Capacity_test_Results_id
UNIQUE USING INDEX Budni_Hydraulic_Lifting_Capacity_test_Results_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_Hydraulic_Maint_of_lift_Load_Results_id
ON Budni_Hydraulic_Maint_of_lift_Load_Results (client_id, function_id, Test_instance_Id , Elapsed_time_min);
ALTER TABLE Budni_Hydraulic_Maint_of_lift_Load_Results
ADD CONSTRAINT unique_Budni_Hydraulic_Maint_of_lift_Load_Results_id
UNIQUE USING INDEX Budni_Hydraulic_Maint_of_lift_Load_Results_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_Brake_Perf_Service_Brake_Test_Results_id
ON Budni_Brake_Perf_Service_Brake_Test_Results (client_id, function_id, Test_instance_Id , Brake_Test_Type,Brake_Test_Name,
Speed_condition,Ballast_Condition,Trial_number);
ALTER TABLE Budni_Brake_Perf_Service_Brake_Test_Results
ADD CONSTRAINT unique_Budni_Brake_Perf_Service_Brake_Test_Results_id
UNIQUE USING INDEX Budni_Brake_Perf_Service_Brake_Test_Results_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_Brake_Perf_Parking_Brake_Test_Results_id
ON Budni_Brake_Perf_Parking_Brake_Test_Results (client_id, function_id, Test_instance_Id , Test_condition);
ALTER TABLE Budni_Brake_Perf_Parking_Brake_Test_Results
ADD CONSTRAINT unique_Budni_Brake_Perf_Parking_Brake_Test_Results_id
UNIQUE USING INDEX Budni_Brake_Perf_Parking_Brake_Test_Results_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_Noise_Atmosp_conditions_id
ON Budni_Noise_Atmosp_conditions (client_id, function_id, Test_instance_Id , Noise_position);
ALTER TABLE Budni_Noise_Atmosp_conditions
ADD CONSTRAINT unique_Budni_Noise_Atmosp_conditions_id
UNIQUE USING INDEX Budni_Noise_Atmosp_conditions_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_Noise_Measurement_Results_id
ON Budni_Noise_Measurement_Results(client_id, function_id, Test_instance_Id , Noise_position, Gear);
ALTER TABLE Budni_Noise_Measurement_Results
ADD CONSTRAINT unique_Budni_Noise_Measurement_Results_id
UNIQUE USING INDEX Budni_Noise_Measurement_Results_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_Vibration_Measurement_id
ON Budni_Vibration_Measurement(client_id, function_id, Test_instance_Id , Measuring_Points,Measuring_point_position);
ALTER TABLE Budni_Vibration_Measurement
ADD CONSTRAINT unique_Budni_Vibration_Measurement_id
UNIQUE USING INDEX Budni_Vibration_Measurement_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_Centre_of_Gravity_Location_id
ON Budni_Centre_of_Gravity_Location(client_id, function_id, Test_instance_Id , condition, Particulars );
ALTER TABLE Budni_Centre_of_Gravity_Location
ADD CONSTRAINT unique_Budni_Centre_of_Gravity_Location_id
UNIQUE USING INDEX Budni_Centre_of_Gravity_Location_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_Field_Perf_Results_id
ON Budni_Field_Perf_Results(client_id, function_id, Test_instance_Id , Parameter_Operation, Name_of_implement );
ALTER TABLE Budni_Field_Perf_Results
ADD CONSTRAINT unique_Budni_Field_Perf_Results_id
UNIQUE USING INDEX Budni_Field_Perf_Results_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_Haulage_Perf_Results_id
ON Budni_Haulage_Perf_Results(client_id, function_id, Test_instance_Id , Wheel_Drive_type );
ALTER TABLE Budni_Haulage_Perf_Results
ADD CONSTRAINT unique_Budni_Haulage_Perf_Results_id
UNIQUE USING INDEX Budni_Haulage_Perf_Results_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_Air_Cleaner_Perf_Results_id
ON Budni_Air_Cleaner_Perf_Results(client_id, function_id, Test_instance_Id , Sequence_Number );
ALTER TABLE Budni_Air_Cleaner_Perf_Results
ADD CONSTRAINT unique_Budni_Air_Cleaner_Perf_Results_id
UNIQUE USING INDEX Budni_Air_Cleaner_Perf_Results_id;
CREATE UNIQUE INDEX CONCURRENTLY Budni_Test_observations_id
ON Budni_Test_observations(client_id, function_id, Test_instance_Id , sequence_number );
ALTER TABLE Budni_Test_observations
ADD CONSTRAINT unique_Budni_Test_observations_id
UNIQUE USING INDEX Budni_Test_observations_id;
CREATE UNIQUE INDEX CONCURRENTLY test_instance_images_id
ON test_instance_images(client_id, function_id, Test_instance_Id , Srl_No );
ALTER TABLE test_instance_images
ADD CONSTRAINT unique_test_instance_images_id
UNIQUE USING INDEX test_instance_images_id;

View File

@@ -0,0 +1,250 @@
/* create the foreign key on client id, function id, test_instance_id in all tables - 20210311 */
CREATE UNIQUE INDEX CONCURRENTLY test_instance_cfs_id
ON test_instance (client_id, function_id, syspk);
ALTER TABLE test_instance
ADD CONSTRAINT unique_test_instance_cfs_id
UNIQUE USING INDEX test_instance_cfs_id;
--alter table Test_instance_tractor_info drop constraint fk_tractor_cf_test_instance_id
ALTER TABLE Test_instance_tractor_info
ADD CONSTRAINT fk_tractor_cfs_test_instance_id
FOREIGN KEY ( client_id, function_Id, test_instance_id)
REFERENCES test_instance( client_id, function_id, syspk);
ALTER TABLE Test_instance_implement_info
ADD CONSTRAINT fk_implement_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Test_instance_trailer_info
ADD CONSTRAINT fk_trailer_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Test_instance_engine_info
ADD CONSTRAINT fk_engine_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE test_instance_tyre_info
ADD CONSTRAINT fk_tyre_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE test_instance_gear_speed_chart
ADD CONSTRAINT fk_gear_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE test_instance_tractor_info_misc
ADD CONSTRAINT fk_tractor_misc_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE test_instance_Wheels_info
ADD CONSTRAINT fk_wheels_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE test_instance_fuel_lubricant_info
ADD CONSTRAINT fk_fuel_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE test_instance_equipment_info
ADD CONSTRAINT fk_equip_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE test_instance_measurement_uncertainty
ADD CONSTRAINT fk_mu_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE test_instance_atmosp_info
ADD CONSTRAINT fk_atmosp_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE test_instance_drawbar_info
ADD CONSTRAINT fk_drawbar_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Field_Perf_Summary_tractor_info
ADD CONSTRAINT fk_fpstractor_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Field_Perf_Summary_implement_info
ADD CONSTRAINT fk_fpsi_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Field_Perf_Summary_Soil_info
ADD CONSTRAINT fk_fpss_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Field_Perf_Summary_trailer_info
ADD CONSTRAINT fk_fpst_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Field_Perf_summary
ADD CONSTRAINT fk_fps_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Drawbar_Perf_results
ADD CONSTRAINT fk_dpr_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Drawbar_Perf_results_summary
ADD CONSTRAINT fk_dprs_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Drawbar_Perf_Noise_Measurement_Results
ADD CONSTRAINT fk_dpnm_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Drawbar_Perf_observations
ADD CONSTRAINT fk_dpo_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE PTO_Perf_results
ADD CONSTRAINT fk_ppr_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE PTO_Perf_Report_Summary
ADD CONSTRAINT fk_pprs_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE PTO_Perf_Report_Details
ADD CONSTRAINT fk_pprd_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE PTO_Perf_test_observations
ADD CONSTRAINT fk_ppto_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE PTO_Key_Perf_Parameters
ADD CONSTRAINT fk_pkpp_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE PTO_smoke_Test
ADD CONSTRAINT fk_pst_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE PTO_Engine_oil_consumption
ADD CONSTRAINT fk_peoc_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE PTO_Multipoint_mapping
ADD CONSTRAINT fk_pmm_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE PTO_Perf_Governing_Graph
ADD CONSTRAINT fk_ppgg_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_PTO_Perf_Results_summary
ADD CONSTRAINT fk_bpprs_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_PTO_Perf_Results_Details
ADD CONSTRAINT fk_bpprd_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_Drawbar_Perf_Results
ADD CONSTRAINT fk_bdpr_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_Hydraulic_Power_test_Results
ADD CONSTRAINT fk_bhptr_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_Hydraulic_Lifting_Capacity_test_Results
ADD CONSTRAINT fk_bhlctr_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_Hydraulic_Maint_of_lift_Load_Results
ADD CONSTRAINT fk_bhmlr_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_Brake_Perf_Service_Brake_Test_Results
ADD CONSTRAINT fk_bbpsb_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_Brake_Perf_Parking_Brake_Test_Results
ADD CONSTRAINT fk_bbppb_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_Noise_Atmosp_conditions
ADD CONSTRAINT fk_bnac_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_Noise_Measurement_Results
ADD CONSTRAINT fk_bnmr_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_Vibration_Measurement
ADD CONSTRAINT fk_bvm_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_Centre_of_Gravity_Location
ADD CONSTRAINT fk_bcg_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_Field_Perf_Results
ADD CONSTRAINT fk_bfpr_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_Haulage_Perf_Results
ADD CONSTRAINT fk_bhpr_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_Air_Cleaner_Perf_Results
ADD CONSTRAINT fk_bacpr_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE Budni_Test_observations
ADD CONSTRAINT fk_bto_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);
ALTER TABLE test_instance_images
ADD CONSTRAINT fk_bti_cfs_test_instance_id
FOREIGN KEY ( client_id, function_id, test_instance_id )
REFERENCES test_instance(client_id, function_id, syspk);

View File

@@ -0,0 +1,15 @@
insert into test_master ( test_name, test_type, test_description) values ( 'Field Perf', 'Field', 'Field Perf Test')
insert into test_lab_location_master ( location_name) values ('Jetsar' );
insert into test_lab_location_master ( location_name) values ('Shivpuri' );
insert into test_lab_location_master ( location_name) values ('Akola' );
insert into test_lab_location_master ( location_name) values ('Sindhnoor' );
insert into test_lab_location_master ( location_name) values ('Tindivanam' );
insert into test_lab_location_master ( location_name) values ('Kumbakonam' );
insert into test_lab_location_master ( location_name) values ('Tadepalligudem' );
insert into test_lab_location_master ( location_name) values ('Punjab' );
insert into test_lab_location_master ( location_name) values ('Other' );
insert into test_lab_location_master ( location_name) values ('Suratgarh (Jetsar)');
insert into test_lab_location_master ( location_name) values ('Sardargarh (Jetsar)');
insert into test_lab_location_master ( location_name) values ('MRV');
insert into test_lab_location_master ( location_name) values ('Budni');

View File

@@ -0,0 +1,52 @@
/* CReate primary key for all the tables in ods */
ALTER TABLE Test_Master ADD CONSTRAINT Test_Master_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Test_Lab_location_Master ADD CONSTRAINT Test_Lab_location_Master_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Test_Instance ADD CONSTRAINT Test_Instance_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Test_instance_tractor_info ADD CONSTRAINT Test_instance_tractor_info_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Test_instance_implement_info ADD CONSTRAINT Test_instance_implement_info_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Test_instance_trailer_info ADD CONSTRAINT Test_instance_trailer_info_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Test_instance_engine_info ADD CONSTRAINT Test_instance_engine_info_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE test_instance_tyre_info ADD CONSTRAINT test_instance_tyre_info_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE test_instance_gear_speed_chart ADD CONSTRAINT test_instance_gear_speed_chart_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE test_instance_tractor_info_misc ADD CONSTRAINT test_instance_tractor_info_misc_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE test_instance_Wheels_info ADD CONSTRAINT test_instance_Wheels_info_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE test_instance_fuel_lubricant_info ADD CONSTRAINT test_instance_fuel_lubricant_info_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE test_instance_equipment_info ADD CONSTRAINT test_instance_equipment_info_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE test_instance_measurement_uncertainty ADD CONSTRAINT test_instance_measurement_uncertainty_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE test_instance_atmosp_info ADD CONSTRAINT test_instance_atmosp_info_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE test_instance_drawbar_info ADD CONSTRAINT test_instance_drawbar_info_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Field_Perf_Summary_tractor_info ADD CONSTRAINT Field_Perf_Summary_tractor_info_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Field_Perf_Summary_implement_info ADD CONSTRAINT Field_Perf_Summary_implement_info_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Field_Perf_Summary_Soil_info ADD CONSTRAINT Field_Perf_Summary_Soil_info_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Field_Perf_Summary_trailer_info ADD CONSTRAINT Field_Perf_Summary_trailer_info_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Field_Perf_summary ADD CONSTRAINT Field_Perf_summary_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Drawbar_Perf_results ADD CONSTRAINT Drawbar_Perf_results_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Drawbar_Perf_results_summary ADD CONSTRAINT Drawbar_Perf_results_summary_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Drawbar_Perf_Noise_Measurement_Results ADD CONSTRAINT Drawbar_Perf_Noise_Measurement_Results_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Drawbar_Perf_observations ADD CONSTRAINT Drawbar_Perf_observations_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE PTO_Perf_results ADD CONSTRAINT PTO_Perf_results_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE PTO_Perf_Report_Summary ADD CONSTRAINT PTO_Perf_Report_Summary_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE PTO_Perf_Report_Details ADD CONSTRAINT PTO_Perf_Report_Details_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE PTO_Perf_test_observations ADD CONSTRAINT PTO_Perf_test_observations_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE PTO_Key_Perf_Parameters ADD CONSTRAINT PTO_Key_Perf_Parameters_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE PTO_smoke_Test ADD CONSTRAINT PTO_smoke_Test_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE PTO_Engine_oil_consumption ADD CONSTRAINT PTO_Engine_oil_consumption_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE PTO_Multipoint_mapping ADD CONSTRAINT PTO_Multipoint_mapping_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE PTO_Perf_Governing_Graph ADD CONSTRAINT PTO_Perf_Governing_Graph_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_PTO_Perf_Results_summary ADD CONSTRAINT Budni_PTO_Perf_Results_summary_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_PTO_Perf_Results_Details ADD CONSTRAINT Budni_PTO_Perf_Results_Details_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_Drawbar_Perf_Results ADD CONSTRAINT Budni_Drawbar_Perf_Results_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_Hydraulic_Power_test_Results ADD CONSTRAINT Budni_Hydraulic_Power_test_Results_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_Hydraulic_Lifting_Capacity_test_Results ADD CONSTRAINT Budni_Hydraulic_Lifting_Capacity_test_Results_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_Hydraulic_Maint_of_lift_Load_Results ADD CONSTRAINT Budni_Hydraulic_Maint_of_lift_Load_Results_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_Brake_Perf_Service_Brake_Test_Results ADD CONSTRAINT Budni_Brake_Perf_Service_Brake_Test_Results_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_Brake_Perf_Parking_Brake_Test_Results ADD CONSTRAINT Budni_Brake_Perf_Parking_Brake_Test_Results_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_Noise_Atmosp_conditions ADD CONSTRAINT Budni_Noise_Atmosp_conditions_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_Noise_Measurement _Results ADD CONSTRAINT Budni_Noise_Measurement _Results_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_Vibration_Measurement ADD CONSTRAINT Budni_Vibration_Measurement_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_Centre_of_Gravity_Location ADD CONSTRAINT Budni_Centre_of_Gravity_Location_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_Field_Perf_Results ADD CONSTRAINT Budni_Field_Perf_Results_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_Haulage_Perf_Results ADD CONSTRAINT Budni_Haulage_Perf_Results_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_Air_Cleaner_Perf_Results ADD CONSTRAINT Budni_Air_Cleaner_Perf_Results_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE Budni_Test_observations ADD CONSTRAINT Budni_Test_observations_syspk_key PRIMARY KEY (SYSPK);
ALTER TABLE test_instance_images ADD CONSTRAINT test_instance_images_syspk_key PRIMARY KEY (SYSPK);