added deployment folder with latest code
This commit is contained in:
@@ -0,0 +1,388 @@
|
||||
drop function if exists mmt_staging2.fn_FTHLG_TRS_ODS ;
|
||||
CREATE OR REPLACE FUNCTION mmt_staging2.fn_FTHLG_TRS_ODS(p_file_syspk int)
|
||||
RETURNS text AS $$
|
||||
declare __test_instance_id int;
|
||||
declare __file_syspk int;
|
||||
declare __test_tractor_id int;
|
||||
declare __test_master_id int;
|
||||
declare v_state text;
|
||||
declare v_msg text;
|
||||
declare v_detail text;
|
||||
declare v_hint text;
|
||||
declare v_context text;
|
||||
declare _error int;
|
||||
begin
|
||||
|
||||
__file_syspk := p_file_syspk;
|
||||
|
||||
/************************************************************
|
||||
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;*/
|
||||
|
||||
select file_syspk into __file_syspk from mmt_staging2.FTHLG_TRS_H1_Block;
|
||||
|
||||
|
||||
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::numeric,
|
||||
Gradient_Slope_2_Degree::numeric,
|
||||
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::numeric tractor_hitch_ht_mm ,
|
||||
Tractor_Rear_Wheel_Center_to_Hitch_Point_Center_Distance_mm::numeric 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::numeric,
|
||||
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::numeric,
|
||||
EPTO_Speed_RPM,
|
||||
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,
|
||||
Ballasted_Tractor_Accessories,
|
||||
Mechanical_Ballast_Rear,
|
||||
Water_Ballast_Rear_75 water_ballast_rear_75_pct,
|
||||
Mechanical_Ballast_Front_in_kg::numeric mechanical_ballast_front_kg,
|
||||
Mechanical_Ballast_Front,
|
||||
Total_Ballast_Weight::numeric,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic
|
||||
from mmt_staging2.fthlg_trs_spec_block where tractor_model is not null and ods_record=1;
|
||||
|
||||
update mmt_ods.test_instance_tractor_info
|
||||
set mahindra_model_yn = (
|
||||
case when tractor_make like 'Mahindra%' then 'Y' else 'N' end
|
||||
) where test_file_ref_no =__file_syspk;
|
||||
|
||||
update mmt_ods.test_instance_tractor_info a
|
||||
set test_tractor_yn ='Y' where syspk in
|
||||
(select min(syspk) from mmt_ods.test_instance_tractor_info b
|
||||
where b.test_file_ref_no =a.test_file_ref_no)
|
||||
and test_file_ref_no =__file_syspk;
|
||||
|
||||
update mmt_ods.test_instance_tractor_info
|
||||
set test_tractor_yn ='N'
|
||||
where test_tractor_yn is null and test_file_ref_no =__file_syspk;
|
||||
|
||||
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::numeric tyre_pressure_psi
|
||||
from mmt_staging2.fthlg_trs_spec_block where front_tyre_make is not null and ods_record=1;
|
||||
|
||||
update mmt_ods.test_instance_tyre_info a
|
||||
set test_instance_tractor_id =(select syspk
|
||||
from mmt_ods.test_instance_tractor_info b
|
||||
where a.test_file_ref_no=b.test_file_ref_no and
|
||||
a.tractor_model=b.tractor_model)
|
||||
where a.tyre_type ='front' and a.test_file_ref_no =__file_syspk;
|
||||
|
||||
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',
|
||||
rear_tyre_make tyre_make,
|
||||
rear_tyre_size tyre_size,
|
||||
rear_tyre_pressure_psi::numeric tyre_pressure_psi
|
||||
from mmt_staging2.fthlg_trs_spec_block where rear_tyre_make is not null and ods_record=1;
|
||||
|
||||
update mmt_ods.test_instance_tyre_info a
|
||||
set test_instance_tractor_id =(select syspk
|
||||
from mmt_ods.test_instance_tractor_info b
|
||||
where a.test_file_ref_no=b.test_file_ref_no and
|
||||
a.tractor_model=b.tractor_model)
|
||||
where a.tyre_type ='rear' and a.test_file_ref_no = __file_syspk;
|
||||
|
||||
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::numeric,
|
||||
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;
|
||||
|
||||
update mmt_ods.test_instance_engine_info a
|
||||
set test_instance_tractor_id =(select syspk
|
||||
from mmt_ods.test_instance_tractor_info b
|
||||
where a.test_file_ref_no=b.test_file_ref_no and
|
||||
a.tractor_model=b.tractor_model)
|
||||
where a.test_file_ref_no = __file_syspk;
|
||||
|
||||
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::numeric,
|
||||
No_Of_Wheels::numeric,
|
||||
Trailer_hitch_Height_above_ground_level_mm::numeric trailer_hitch_ht_above_ground_lvl_mm,
|
||||
Make_model_of_trailer,
|
||||
Trailer_platform_length_mm::numeric,
|
||||
Trailer_platform_Width_mm::numeric,
|
||||
Trailer_platform_Height_mm::numeric,
|
||||
Tire_size,
|
||||
Inflation_pressure_psi::numeric,
|
||||
Track_width_of_trailer_mm::numeric,
|
||||
Horizontal_distance_of_hitch_point_from_trailer_front_face_mm::numeric hzntl_dist_of_hitch_pt_from_trailer_face_mm,
|
||||
Tractor_Rear_Wheel_Center_to_Hitch_Point_Center_Distance_mm::numeric tractor_rwc_to_hitch_pt_center_dist_mm,
|
||||
Distance_from_Trailerfront_axle_distance_from_hitch_point_mm::numeric dist_from_tractor_rwc_to_trailer_rwc_mm,
|
||||
Distance_from_tractor_rear_wheel_center_to_tractor_rear_wheel_center_mm::numeric dist_from_trailer_front_axle_dist_from_hitch_pt_mm,
|
||||
Trailer_empty_weight_Kg::numeric,
|
||||
Trailer_Gross_Weight_Kg::numeric,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic
|
||||
from mmt_staging2.fthlg_trs_trailer_block where type_of_trailer is not null and no_of_axle 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 syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
select syspk from mmt_ods.test_master into __test_master_id where test_type ='Field';
|
||||
select syspk from mmt_ods.test_instance_tractor_info into __test_tractor_id
|
||||
where test_file_ref_no =__file_syspk and test_tractor_yn ='Y';
|
||||
|
||||
update mmt_ods.test_instance
|
||||
set test_master_id =__test_master_id,
|
||||
test_tractor_id =__test_tractor_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.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;
|
||||
|
||||
v_context := '';
|
||||
perform mmt_staging2.mmt_insert_db_error ( null, null, 1001, 'Compegence', __file_syspk ,'FTHLG','FTHLG_TRS' ,null,'ods', 'fn_FTHLG_TRS_ODS', v_state, v_msg, v_detail, v_hint, v_context,'success');
|
||||
return v_context;
|
||||
|
||||
EXCEPTION when OTHERS then
|
||||
|
||||
GET STACKED DIAGNOSTICS
|
||||
v_state = returned_sqlstate,
|
||||
v_msg = message_text,
|
||||
v_detail = pg_exception_detail,
|
||||
v_hint = pg_exception_hint,
|
||||
v_context = pg_exception_context;
|
||||
|
||||
perform mmt_staging2.mmt_insert_db_error ( null, null, 1001, 'Compegence', __file_syspk ,'FTHLG','FTHLG_TRS' ,null,'ods', 'fn_FTHLG_TRS_ODS', v_state, v_msg, v_detail, v_hint, v_context,'error');
|
||||
return v_context;
|
||||
end
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user