179 lines
3.7 KiB
PL/PgSQL
179 lines
3.7 KiB
PL/PgSQL
drop function if exists mmt_staging2.fn_FTDRY_TRS_ODS ;
|
|
CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTDRY_TRS_ODS()
|
|
RETURNS void AS $$
|
|
begin
|
|
|
|
execute 'insert into mmt_ods.test_instance
|
|
(
|
|
client_id,
|
|
function_id,
|
|
test_file_ref_no ,
|
|
test_report_no,
|
|
objective_of_test,
|
|
background_of_test,
|
|
job_order_no,
|
|
test_location_name,
|
|
soil_moisture_content_pct,
|
|
soil_bulk_density_g_per_cc,
|
|
test_engineer,
|
|
test_operator,
|
|
date_of_test,
|
|
test_report_date,
|
|
season,
|
|
type_of_soil,
|
|
soil_cone_index,
|
|
field_condition
|
|
)
|
|
select
|
|
client_id,function_id,
|
|
file_number,
|
|
report_reference_no test_report_no,
|
|
objective_of_test,
|
|
background_of_test,
|
|
job_order_no,
|
|
test_location test_location_name,
|
|
soil_moisture_content_::int soil_moisture_content_pct ,
|
|
soil_bulk_density_g_cc::int soil_bulk_density_g_per_cc,
|
|
test_engineer,
|
|
test_operator,
|
|
date_of_test::date,
|
|
report_date::date test_report_date,
|
|
season,
|
|
type_of_soil,
|
|
soil_cone_index_kpa::int soil_cone_index,
|
|
field_condition
|
|
from mmt_staging2.ftdry_trs_h1_block';
|
|
|
|
|
|
exceute 'insert into mmt_ods.test_instance_tractor_info
|
|
(
|
|
client_id,
|
|
function_id,
|
|
tractor_model,
|
|
tractor_make,
|
|
tractor_sr_no,
|
|
tractor_engine_hp,
|
|
fip_type,
|
|
hour_Meter_Reading,
|
|
Steering_Type,
|
|
Transmission_Type,
|
|
wheel_drive_type,
|
|
egr_yn,
|
|
Brake_Type,
|
|
PTO_Type,
|
|
Standard_PTO_Speed_RPM,
|
|
EPTO_Speed_RPM,
|
|
tractor_weight_front_kg,
|
|
tractor_weight_rear_kg,
|
|
tractor_weight_total_kg,
|
|
Ballasted_Tractor_Accessories,
|
|
Mechanical_Ballast_Rear,
|
|
mechanical_ballast_rear_in_kg,
|
|
water_ballast_rear_75_pct ,
|
|
Mechanical_Ballast_Front,
|
|
mechanical_ballast_front_kg ,
|
|
Total_Ballast_Weight,
|
|
test_file_ref_no
|
|
)
|
|
select
|
|
client_id,
|
|
function_id,
|
|
Tractor_Model,
|
|
Tractor_Make,
|
|
Tractor_Sr_No,
|
|
Tractor_Engine_HP::float,
|
|
FIP_Type,
|
|
hour_Meter_Reading::int,
|
|
Steering_Type,
|
|
Transmission_Type,
|
|
Wheel_Drive_Type_WD wheel_drive_type ,
|
|
EGR_Yes_No egr_yn,
|
|
Brake_Type ,
|
|
PTO_Type ,
|
|
Standard_PTO_Speed_RPM::int,
|
|
EPTO_Speed_RPM::int,
|
|
Tractor_Weight_kg_Front::int tractor_weight_front_kg ,
|
|
Tractor_Weight_kg_Rear::int tractor_weight_rear_kg ,
|
|
Tractor_Weight_kg_Total::int tractor_weight_total_kg ,
|
|
Ballasted_Tractor_Accessories,
|
|
Mechanical_Ballast_Rear,
|
|
Mechanical_Ballast_Rear_in_KG::int mechanical_ballast_rear_in_kg ,
|
|
Water_Ballast_Rear water_ballast_rear_75_pct ,
|
|
Mechanical_Ballast_Front,
|
|
Mechanical_Ballast_Front_in_Kg::int mechanical_ballast_front_kg ,
|
|
Total_Ballast_Weight::int,
|
|
file_number
|
|
from mmt_staging2.ftdry_trs_spec_block'
|
|
|
|
|
|
|
|
execute 'insert into mmt_ods.test_instance_engine_info
|
|
(
|
|
client_id,
|
|
function_id,
|
|
low_idle_observed ,
|
|
high_idle_observed ,
|
|
rated_rpm_observed ,
|
|
engine_to_pto_ratio_540_pto,
|
|
engine_to_pto_ratio_540e_pto,
|
|
tractor_model,
|
|
tractor_make,
|
|
test_file_ref_no
|
|
)
|
|
select
|
|
client_id,
|
|
function_id,
|
|
low_idle::int low_idle_observed ,
|
|
high_idle::int high_idle_observed ,
|
|
rated_rpm::int rated_rpm_observed
|
|
,engine_to_pto_ratio_540_pto,
|
|
engine_to_pto_ratio_540e_pto,
|
|
file_number
|
|
from mmt_staging2.ftdry_trs_engine_rpm_block
|
|
where tractor_model is not null'
|
|
|
|
|
|
|
|
execute 'insert into mmt_ods.test_instance_implement_info
|
|
(
|
|
client_id,
|
|
function_id,
|
|
name_of_implement,
|
|
type_of_implement,
|
|
make_of_implement,
|
|
no_of_disc_blades_bottoms,
|
|
cutting_width_m,
|
|
implement_weight_kg,
|
|
hitch_category,
|
|
span_for_mounted_implement_cm,
|
|
mast_height_for_mounted_implement_cm,
|
|
test_file_ref_no
|
|
)
|
|
select
|
|
client_id,
|
|
function_id,
|
|
name_of_implement,
|
|
type_of_implement,
|
|
make_of_implement,
|
|
no_of_bottoms_tyne_disc_blade::int no_of_disc_blades_bottoms,
|
|
cutting_width_m,
|
|
implement_weight_kg::int,
|
|
hitch_category,
|
|
span_cm_for_mounted_implement::int span_for_mounted_implement_cm ,
|
|
mast_height_cm_for_mounted_implement::int mast_height_for_mounted_implement_cm,
|
|
file_number
|
|
from mmt_staging2.ftdry_trs_implement_block;
|
|
|
|
|
|
end
|
|
$$ LANGUAGE plpgsql;
|
|
|
|
select mmt_staging2.fn_FTDRY_TRS_ODS();
|
|
|
|
|
|
|
|
from mmt_staging2.ftdry_trs_implement_block where name_of_implement is not null;
|
|
|
|
end
|
|
$$ LANGUAGE plpgsql;
|