sql files
This commit is contained in:
459
onetime/dataloadfunctions/IHT/IHTBT30_BT30_ODS.sql
Executable file
459
onetime/dataloadfunctions/IHT/IHTBT30_BT30_ODS.sql
Executable file
@@ -0,0 +1,459 @@
|
||||
drop function if exists staging2.fn_IHTBT30_BT30_TRX;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTBT30_BT30_TRX(p_client_id int,p_function_id int, p_file_mnemonic text,
|
||||
p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __test_instance_id int;
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare _error int;
|
||||
declare __test_master_id int;
|
||||
declare __test_instance_tractor_id int;
|
||||
begin
|
||||
__file_syspk := p_file_syspk;
|
||||
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTBT30_BT30_TRX
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHT
|
||||
Sheet Format: IHTBT30_BT30
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTBT30_BT30_TRX()
|
||||
***************************************************************/
|
||||
insert into transactional.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
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,
|
||||
objective_of_test,
|
||||
test_condition,
|
||||
test_standard_desc,
|
||||
test_standard_id,
|
||||
acceptance_criteria,
|
||||
remarks,
|
||||
observations
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
Test_Request_no,
|
||||
sample_receipt_date::date,
|
||||
Test_report_No,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date::date,
|
||||
No_of_Sample,
|
||||
Test_Start_Date::date,
|
||||
Test_End_Date::date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Ref,
|
||||
test_location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
condition,
|
||||
test_standard,
|
||||
test_standard_id::numeric,
|
||||
acceptance_criteria,
|
||||
remarks,
|
||||
observations
|
||||
from
|
||||
staging2.IHTBT30_BT30_H1_block where trx_record =1;
|
||||
|
||||
update transactional.test_instance a
|
||||
set
|
||||
report_prepared_date=to_date(b.prepared_date,'DD-MM-YYYY'),
|
||||
report_reviewed_date=to_date(b.reviewed_date,'DD-MM-YYYY'),
|
||||
report_approved_date=to_date(b.approved_date,'DD-MM-YYYY'),
|
||||
report_prepared_by=b.prepared_by,
|
||||
report_reviewed_by=b.reviewed_by,
|
||||
report_approved_by=b.approved_by,
|
||||
report_template_replaces=b.replaces,
|
||||
report_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from staging2.IHTBT30_BT30_footer_block b
|
||||
where a.file_sheet_mnemonic='IHTBT30_BT30' and trx_record =1;
|
||||
|
||||
|
||||
|
||||
insert into transactional.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tyre_type,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
tyre_ply_rating,
|
||||
tyre_use_type,
|
||||
tyre_pressure_kg_per_cm2
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
tyre_details,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
ply_rating::numeric,
|
||||
tyre_use_type,
|
||||
pressure_kg_cm2::numeric
|
||||
from staging2.IHTBT30_BT30_tyre_details_block where trx_record =1;
|
||||
|
||||
|
||||
insert into transactional.test_instance_drawbar_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
weight_front_kg,
|
||||
weight_rear_kg,
|
||||
weight_total_kg
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
test_condition,
|
||||
front::numeric ,
|
||||
rear::numeric ,
|
||||
total::numeric
|
||||
from staging2.IHTBT30_BT30_weight_block where trx_record =1;
|
||||
|
||||
|
||||
/*block */
|
||||
|
||||
insert into transactional.test_instance_tractor_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tractor_platform
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
platform
|
||||
from staging2.IHTBT30_BT30_h1_block where trx_record =1;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set mahindra_model_yn = (
|
||||
case when tractor_make like 'Mahindra%' then 'Y' else 'N' end
|
||||
) where file_syspk =__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info a
|
||||
set test_tractor_yn ='Y' where syspk in
|
||||
(select min(syspk) from transactional.test_instance_tractor_info b
|
||||
where b.file_syspk =a.file_syspk)
|
||||
and a.file_syspk =__file_syspk;
|
||||
|
||||
|
||||
|
||||
insert into transactional.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
observation,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column10
|
||||
from staging2.IHTBT30_BT30_test_res_1_block where trx_record =1;
|
||||
|
||||
insert into transactional.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
observation,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column10
|
||||
from staging2.IHTBT30_BT30_test_res_2_block where trx_record =1;
|
||||
|
||||
insert into transactional.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
observation,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column10
|
||||
from staging2.IHTBT30_BT30_test_res_3_block where trx_record =1;
|
||||
|
||||
insert into transactional.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
observation,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column10
|
||||
from staging2.IHTBT30_BT30_test_res_4_block where trx_record =1;
|
||||
|
||||
insert into transactional.iht_brake_perf_test_condition
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
date_of_test,
|
||||
time_of_test,
|
||||
location_name,
|
||||
test_mode,
|
||||
wind_velocity_kmph,
|
||||
ambient_temp_c,
|
||||
humidity_rh_pct
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,
|
||||
model,
|
||||
condition,
|
||||
date::date,
|
||||
time,
|
||||
location,
|
||||
mode,
|
||||
wind_velocity_km_hr,
|
||||
ambient_temperature_c::numeric ,
|
||||
humidity_rh::numeric
|
||||
from staging2.IHTBT30_BT30_test_condition_block where trx_record =1;
|
||||
|
||||
update transactional.iht_brake_perf_test_results a
|
||||
set brake_perf_test_condition_id=(select syspk
|
||||
from transactional.iht_brake_perf_test_condition b
|
||||
where a.test_mode =b.test_mode and a.test_condition=b.test_condition and a.file_syspk=b.file_syspk)
|
||||
where a.file_syspk =__file_syspk;
|
||||
|
||||
|
||||
select syspk into __test_instance_id from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_model into __model from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_make into __make from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select syspk from transactional.test_master into __test_master_id where test_type ='In House';
|
||||
select syspk into __test_instance_tractor_id from transactional.test_instance_tractor_info where file_syspk =__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance
|
||||
set test_master_id =__test_master_id,
|
||||
test_tractor_id =__test_instance_tractor_id
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.test_instance_drawbar_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.iht_brake_perf_test_condition
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.iht_brake_perf_test_results
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'trx', 'fn_IHTBT30_BT30_TRX', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
908
onetime/dataloadfunctions/IHT/IHTBT30_BT30_STG2.sql
Executable file
908
onetime/dataloadfunctions/IHT/IHTBT30_BT30_STG2.sql
Executable file
@@ -0,0 +1,908 @@
|
||||
drop function if exists staging2.fn_IHTBT30_BT30_block;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTBT30_BT30_block(p_client_id int,p_function_id int, p_file_mnemonic text,p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare err_query int;
|
||||
declare err_block text;
|
||||
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTBT30_BT30_block
|
||||
Function Desc: This function populates data into staging 2 block
|
||||
File Format: IHT
|
||||
Sheet Format: IHTBT30_BT30
|
||||
Creation Date: March 25 2021
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTBT30_BT30_block(p_client_id,p_function_id, p_file_mnemonic,
|
||||
p_file_sheet_mnemonic, p_file_syspk)
|
||||
Function call ex: select staging2.fn_IHTBT30_BT30_block(1,2,'IHT','IHTBT30_BT30',456)
|
||||
***************************************************************/
|
||||
|
||||
|
||||
SET search_path TO staging2;
|
||||
|
||||
/* to process multiple files - re-runnability*/
|
||||
|
||||
truncate table staging2.IHTBT30_BT30_H1_INT;
|
||||
truncate table staging2.IHTBT30_BT30_H1_block;
|
||||
truncate table staging2.IHTBT30_BT30_Weight_Tyre_Int;
|
||||
truncate table staging2.IHTBT30_BT30_Weight_Block;
|
||||
truncate table staging2.IHTBT30_BT30_Tyre_Details_Block;
|
||||
truncate table staging2.IHTBT30_BT30_Test_Res_1_Block;
|
||||
truncate table staging2.IHTBT30_BT30_Test_Res_2_Block;
|
||||
truncate table staging2.IHTBT30_BT30_Test_Res_3_Block;
|
||||
truncate table staging2.IHTBT30_BT30_Test_Res_4_Block;
|
||||
truncate table staging2.IHTBT30_BT30_Test_Condition_Block;
|
||||
truncate table staging2.IHTBT30_BT30_Footer_Block;
|
||||
truncate table staging2.stg_specific_table_IHTBT30_BT30;
|
||||
truncate table staging2.stg_process_table_IHTBT30_BT30;
|
||||
|
||||
|
||||
execute 'delete from fw_core.fw_jobctl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=null,
|
||||
row_previous_number=null,
|
||||
row_read_end=null,
|
||||
run_time=null
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* transfer data from generic to specific for IHT */
|
||||
execute 'insert into staging2.stg_specific_table_IHTBT30_BT30
|
||||
select * from staging1.staging_generic_table a
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''
|
||||
and a.file_syspk='||p_file_syspk||'';
|
||||
|
||||
select count(*) into err_query from staging2.stg_specific_table_IHTBT30_BT30;
|
||||
|
||||
if err_query=0 then
|
||||
err_context := 'data not present';
|
||||
raise exception using
|
||||
message = 'No Data for IHTBT30',
|
||||
detail = 'No data in table stg_specific_table_IHTBT30_BT30',
|
||||
errcode = '42704',
|
||||
hint = 'check sheet mnemonic in generic table, if it is null update it';
|
||||
end if;
|
||||
|
||||
/* trimming data */
|
||||
update staging2.stg_specific_table_IHTBT30_BT30
|
||||
set column10='Objective' where lower(column10) like 'objective%';
|
||||
|
||||
update staging2.stg_specific_table_IHTBT30_BT30
|
||||
set column10='Acceptance criteria' where lower(column10) like 'acceptance criteria%';
|
||||
|
||||
|
||||
update staging2.stg_specific_table_IHTBT30_BT30
|
||||
set column10='Condition' where lower(column10) like 'condition%';
|
||||
|
||||
update transactional.source_config set F1_source=F1_modified ;
|
||||
|
||||
/* keyword match in config table*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=(select min(b.row_number)
|
||||
from staging2.stg_specific_table_IHTBT30_BT30 b
|
||||
where upper(F1_modified)=upper(column3)
|
||||
and b.is_rownumber_fetched is null)
|
||||
where a.row_number_start is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* reverese update in process table for match*/
|
||||
execute 'update staging2.stg_specific_table_IHTBT30_BT30 a
|
||||
set is_rownumber_fetched=1
|
||||
from transactional.source_config b
|
||||
where upper(F1_modified)=upper(column3)
|
||||
and b.row_number_start=a.row_number
|
||||
and is_rownumber_fetched is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'update transactional.source_config a set row_previous_number=row_number_start-1
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* update config files for row numbers start, end */
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end= (select b.row_number_start
|
||||
from transactional.source_config b
|
||||
where b.syspk=a.syspk+1 and file_mnemonic='''||p_file_mnemonic||''' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||''' )
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* config file last field update as null otherwise it picks up next format row number*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end = null ,run_time=current_timestamp
|
||||
where f1_modified =''Prepared by''
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* tagging block_row_numbers*/
|
||||
execute 'insert into staging2.stg_process_table_IHTBT30_BT30
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTBT30_BT30 a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Test Request No''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTBT30_BT30
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTBT30_BT30 a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Un-Ballast cold''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTBT30_BT30
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTBT30_BT30 a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Ballast cold''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTBT30_BT30
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTBT30_BT30 a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Fade Performance''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTBT30_BT30
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTBT30_BT30 a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Recovery Performance''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTBT30_BT30
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTBT30_BT30 a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Weight (kg)''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTBT30_BT30
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTBT30_BT30 a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Prepared by''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/*selecting tractor model*/
|
||||
select column5 into __model from staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where block_tag='IHTBT30_BT30_H1' and trim(column3)='Tractor Model';
|
||||
|
||||
/*block starts - IHTBT30_BT30_H1_BLOCK */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT30_BT30_H1_BLOCK',__file_mnemonic,__file_sheet_mnemonic,1);
|
||||
err_block:='IHTBT30_BT30_H1_BLOCK';
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select a.column3,column5 from staging2.stg_process_table_IHTBT30_BT30 a where block_tag='IHTBT30_BT30_H1'
|
||||
and block_row_number <=9;
|
||||
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select a.column7,column9 from staging2.stg_process_table_IHTBT30_BT30 a where block_tag='IHTBT30_BT30_H1'
|
||||
and block_row_number <=9;
|
||||
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select 'Objective',column10
|
||||
from staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where block_tag='IHTBT30_BT30_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where column10='Objective'
|
||||
and block_tag='IHTBT30_BT30_H1'
|
||||
);
|
||||
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select 'Acceptance criteria',column8
|
||||
from staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where block_tag='IHTBT30_BT30_H1' and block_row_number=11;
|
||||
|
||||
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select 'Condition',column10
|
||||
from staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where block_tag='IHTBT30_BT30_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where column10='Condition'
|
||||
and block_tag='IHTBT30_BT30_H1'
|
||||
);
|
||||
|
||||
|
||||
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select 'Test std',column4
|
||||
from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where block_row_number=11
|
||||
and block_tag='IHTBT30_BT30_H1';
|
||||
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select 'Test std Id',column3
|
||||
from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where block_row_number=11
|
||||
and block_tag='IHTBT30_BT30_H1';
|
||||
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select 'Test Standard ref',split_part(column3,':',2)
|
||||
from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where block_row_number=10
|
||||
and block_tag='IHTBT30_BT30_H1';
|
||||
|
||||
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select 'Observations',column3
|
||||
from staging2.stg_process_table_IHTBT30_BT30
|
||||
where block_tag='IHTBT30_BT30_Weight_Tyre'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where column3='Remarks & Observations'
|
||||
and block_tag='IHTBT30_BT30_Weight_Tyre'
|
||||
);
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_H1_Int set model=__model;
|
||||
execute 'update staging2.IHTBT30_BT30_H1_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
insert into staging2.IHTBT30_BT30_H1_Block
|
||||
(
|
||||
dummy_f,
|
||||
Test_Request_no,
|
||||
Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Tractor_Model,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date,
|
||||
Test_Location,
|
||||
No_of_Sample,
|
||||
Test_Start_Date,
|
||||
Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Domestic_Export,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Platform,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
condition,
|
||||
Test_Standard,
|
||||
Test_Standard_id,
|
||||
Test_Standard_ref,
|
||||
Remarks,
|
||||
Observations
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{c2}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[c2::text]) AS val
|
||||
FROM staging2.IHTBT30_BT30_H1_INT
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,
|
||||
a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,
|
||||
a_18 text,a_19 text,a_20 text,a_21 text,a_22 text,a_23 text,a_24 text,a_25 text,a_26 text);
|
||||
|
||||
update staging2.IHTBT30_BT30_H1_Block
|
||||
set Sample_Receipt_Date=case
|
||||
when Sample_Receipt_Date like '%-%' then Sample_Receipt_Date::timestamptz
|
||||
else date '1899-12-30' + Sample_Receipt_Date::int * interval '1' day
|
||||
end;
|
||||
|
||||
update staging2.IHTBT30_BT30_H1_Block
|
||||
set Test_Report_Date=case
|
||||
when Test_Report_Date like '%-%' then Test_Report_Date::timestamptz
|
||||
else date '1899-12-30' + Test_Report_Date::int * interval '1' day
|
||||
end;
|
||||
|
||||
update staging2.IHTBT30_BT30_H1_Block
|
||||
set Test_Start_Date=case
|
||||
when Test_Report_Date like '%-%' then Test_Report_Date::timestamptz
|
||||
else date '1899-12-30' + Test_Report_Date::int * interval '1' day
|
||||
end;
|
||||
update staging2.IHTBT30_BT30_H1_Block
|
||||
set Test_End_Date=case
|
||||
when Test_Report_Date like '%-%' then Test_Report_Date::timestamptz
|
||||
else date '1899-12-30' + Test_Report_Date::int * interval '1' day
|
||||
end;
|
||||
|
||||
delete from staging2.IHTBT30_BT30_H1_Block where dummy_f is null ;
|
||||
update staging2.IHTBT30_BT30_H1_Block set model=__model;
|
||||
execute 'update staging2.IHTBT30_BT30_H1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT30_BT30_H1_BLOCK');
|
||||
|
||||
|
||||
insert into staging2.IHTBT30_BT30_Weight_Tyre_Int
|
||||
(
|
||||
column3,column4,column5,column6,column7,column8,column9,
|
||||
column10,column11,column12,block_row_number
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column7,column8,
|
||||
column9,column10,column11,column12,block_row_number
|
||||
from staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where block_tag='IHTBT30_BT30_Weight_Tyre'
|
||||
order by block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Weight_Tyre_Int set model=__model;
|
||||
execute 'update staging2.IHTBT30_BT30_Weight_Tyre_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
/*block starts - IHTBT30_BT30_Weight_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT30_BT30_Weight_Block',__file_mnemonic,__file_sheet_mnemonic,2);
|
||||
err_block:='IHTBT30_BT30_Weight_Block';
|
||||
insert into staging2.IHTBT30_BT30_Weight_Block
|
||||
(
|
||||
dummy_f,
|
||||
test_condition,
|
||||
Front,
|
||||
Rear,
|
||||
Total
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column5,column7}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column5::text,column7::text]) AS val
|
||||
FROM staging2.IHTBT30_BT30_Weight_Tyre_Int where column5 is not null and column7 is not null and block_row_number<>1
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text);
|
||||
|
||||
|
||||
delete from staging2.IHTBT30_BT30_Weight_Block where dummy_f is null ;
|
||||
update staging2.IHTBT30_BT30_Weight_Block set model=__model;
|
||||
execute 'update staging2.IHTBT30_BT30_Weight_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT30_BT30_Weight_Block');
|
||||
|
||||
/*block starts - IHTBT30_BT30_Tyre_Details_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT30_BT30_Tyre_Details_Block',__file_mnemonic,__file_sheet_mnemonic,3);
|
||||
err_block:='IHTBT30_BT30_Tyre_Details_Block';
|
||||
insert into staging2.IHTBT30_BT30_Tyre_Details_Block
|
||||
(
|
||||
dummy_f,
|
||||
Tyre_Details,
|
||||
Pressure_kg_cm2,
|
||||
tyre_use_type,
|
||||
Tyre_Make,
|
||||
tyre_size,
|
||||
ply_rating
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column10,column11}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column10::text,column11::text]) AS val
|
||||
FROM staging2.IHTBT30_BT30_Weight_Tyre_Int where column11 is not null or column10 is not null
|
||||
ORDER BY generate_series(1,15),block_row_number,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text);
|
||||
|
||||
|
||||
|
||||
delete from staging2.IHTBT30_BT30_Tyre_Details_Block where dummy_f is null ;
|
||||
update staging2.IHTBT30_BT30_Tyre_Details_Block set model=__model;
|
||||
execute 'update staging2.IHTBT30_BT30_Tyre_Details_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT30_BT30_Tyre_Details_Block');
|
||||
|
||||
|
||||
/*block starts - IHTBT30_BT30_Test_Res_1_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT30_BT30_Test_Res_1_Block',__file_mnemonic,__file_sheet_mnemonic,4);
|
||||
err_block:='IHTBT30_BT30_Test_Res_1_Block';
|
||||
|
||||
insert into staging2.IHTBT30_BT30_Test_Res_1_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
from staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where block_tag='IHTBT30_BT30_Test_Res_1'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_1_Block
|
||||
set column2=column3 where block_row_number=1;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_1_Block a
|
||||
set column2= b.first_value from (SELECT
|
||||
block_row_number,column2, value_partition, first_value(column2) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column2,
|
||||
sum(case when column2 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT30_BT30_Test_Res_1_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_1_Block a
|
||||
set column10= b.first_value from (SELECT
|
||||
block_row_number,column10, value_partition, first_value(column10) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column10,
|
||||
sum(case when column10 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT30_BT30_Test_Res_1_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_1_Block set trx_record =0 where block_row_number in (1,2,3,4);
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_1_Block set trx_record =0
|
||||
where column4 is null and column5 is null;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_1_Block set model=__model;
|
||||
execute 'update staging2.IHTBT30_BT30_Test_Res_1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT30_BT30_Test_Res_1_Block');
|
||||
|
||||
|
||||
/*block starts - IHTBT30_BT30_Test_Res_2_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT30_BT30_Test_Res_2_Block',__file_mnemonic,__file_sheet_mnemonic,5);
|
||||
err_block:='IHTBT30_BT30_Test_Res_2_Block';
|
||||
|
||||
insert into staging2.IHTBT30_BT30_Test_Res_2_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
from staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where block_tag='IHTBT30_BT30_Test_Res_2'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_2_Block
|
||||
set column2=column3 where block_row_number=1;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_2_Block a
|
||||
set column2= b.first_value from (SELECT
|
||||
block_row_number,column2, value_partition, first_value(column2) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
select
|
||||
block_row_number,
|
||||
column2,
|
||||
sum(case when column2 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT30_BT30_Test_Res_2_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_2_Block a
|
||||
set column10= b.first_value from (SELECT
|
||||
block_row_number,column10, value_partition, first_value(column10) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column10,
|
||||
sum(case when column10 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT30_BT30_Test_Res_2_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_2_Block set trx_record =0 where block_row_number in (1,2,3,4);
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_2_Block set trx_record =0
|
||||
where column4 is null and column5 is null;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_2_Block set model=__model;
|
||||
execute 'update staging2.IHTBT30_BT30_Test_Res_2_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT30_BT30_Test_Res_2_Block');
|
||||
|
||||
|
||||
/*block starts - IHTBT30_BT30_Test_Res_3_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT30_BT30_Test_Res_3_Block',__file_mnemonic,__file_sheet_mnemonic,6);
|
||||
err_block:='IHTBT30_BT30_Test_Res_3_Block';
|
||||
|
||||
insert into staging2.IHTBT30_BT30_Test_Res_3_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
from staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where block_tag='IHTBT30_BT30_Test_Res_3'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_3_Block
|
||||
set column2=column3 where block_row_number=1;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_3_Block a
|
||||
set column2= b.first_value from (SELECT
|
||||
block_row_number,column2, value_partition, first_value(column2) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column2,
|
||||
sum(case when column2 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT30_BT30_Test_Res_3_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_3_Block a
|
||||
set column10= b.first_value from (SELECT
|
||||
block_row_number,column10, value_partition, first_value(column10) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column10,
|
||||
sum(case when column10 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT30_BT30_Test_Res_3_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_3_Block set trx_record =0 where block_row_number in (1,2,3,4);
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_3_Block set trx_record =0
|
||||
where column4 is null and column5 is null;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_3_Block set model=__model;
|
||||
execute 'update staging2.IHTBT30_BT30_Test_Res_3_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT30_BT30_Test_Res_3_Block');
|
||||
|
||||
|
||||
/*block starts - IHTBT30_BT30_Test_Res_4_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT30_BT30_Test_Res_4_Block',__file_mnemonic,__file_sheet_mnemonic,7);
|
||||
err_block:='IHTBT30_BT30_Test_Res_4_Block';
|
||||
|
||||
insert into staging2.IHTBT30_BT30_Test_Res_4_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
from staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where block_tag='IHTBT30_BT30_Test_Res_4'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_4_Block
|
||||
set column2=column3 where block_row_number=1;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_4_Block a
|
||||
set column2= b.first_value from (SELECT
|
||||
block_row_number,column2, value_partition, first_value(column2) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column2,
|
||||
sum(case when column2 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT30_BT30_Test_Res_4_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_4_Block a
|
||||
set column10= b.first_value from (SELECT
|
||||
block_row_number,column10, value_partition, first_value(column10) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column10,
|
||||
sum(case when column10 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT30_BT30_Test_Res_4_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_4_Block set trx_record =0 where block_row_number in (1,2,3,4,15);
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_4_Block set trx_record =0
|
||||
where column4 is null and column5 is null;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_4_Block set model=__model;
|
||||
execute 'update staging2.IHTBT30_BT30_Test_Res_4_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT30_BT30_Test_Res_4_Block');
|
||||
|
||||
|
||||
/*block starts - IHTBT30_BT30_Test_Condition_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT30_BT30_Test_Condition_Block',__file_mnemonic,__file_sheet_mnemonic,8);
|
||||
err_block:='IHTBT30_BT30_Test_Condition_Block';
|
||||
|
||||
|
||||
insert into staging2.IHTBT30_BT30_Test_Condition_Block (condition)
|
||||
select column2 from staging2.IHTBT30_BT30_Test_Res_1_Block
|
||||
where block_row_number=2
|
||||
union
|
||||
select column2 from staging2.IHTBT30_BT30_Test_Res_2_Block
|
||||
where block_row_number=2
|
||||
union
|
||||
select column2 from staging2.IHTBT30_BT30_Test_Res_3_Block
|
||||
where block_row_number=2
|
||||
union
|
||||
select column2 from staging2.IHTBT30_BT30_Test_Res_4_Block
|
||||
where block_row_number=2;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set date=b.column4,
|
||||
location=b.column7,
|
||||
--time=b.column9,
|
||||
mode=b.column10
|
||||
from staging2.IHTBT30_BT30_Test_Res_1_Block b
|
||||
where b.block_row_number =2 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set Wind_Velocity_Km_hr=b.column5,
|
||||
Ambient_Temperature_C=b.column7,
|
||||
Humidity_RH=b.column9
|
||||
from staging2.IHTBT30_BT30_Test_Res_1_Block b
|
||||
where b.block_row_number =3 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set date=b.column4,
|
||||
location=b.column7,
|
||||
--time=b.column9,
|
||||
mode=b.column10
|
||||
from staging2.IHTBT30_BT30_Test_Res_2_Block b
|
||||
where b.block_row_number =2 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set Wind_Velocity_Km_hr=b.column5,
|
||||
Ambient_Temperature_C=b.column7,
|
||||
Humidity_RH=b.column9
|
||||
from staging2.IHTBT30_BT30_Test_Res_2_Block b
|
||||
where b.block_row_number =3 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set date=b.column4,
|
||||
location=b.column7,
|
||||
--time=b.column9,
|
||||
mode=b.column10
|
||||
from staging2.IHTBT30_BT30_Test_Res_3_Block b
|
||||
where b.block_row_number =2 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set Wind_Velocity_Km_hr=b.column5,
|
||||
Ambient_Temperature_C=b.column7,
|
||||
Humidity_RH=b.column9
|
||||
from staging2.IHTBT30_BT30_Test_Res_3_Block b
|
||||
where b.block_row_number =3 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set date=b.column4,
|
||||
location=b.column7,
|
||||
--time=b.column9,
|
||||
mode=b.column10
|
||||
from staging2.IHTBT30_BT30_Test_Res_4_Block b
|
||||
where b.block_row_number =2 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set Wind_Velocity_Km_hr=b.column5,
|
||||
Ambient_Temperature_C=b.column7,
|
||||
Humidity_RH=b.column9
|
||||
from staging2.IHTBT30_BT30_Test_Res_4_Block b
|
||||
where b.block_row_number=3 and condition=b.column2;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Condition_Block a
|
||||
set date= case
|
||||
when date like '%-%' then date::timestamptz
|
||||
else date '1899-12-30' + date::int * interval '1' day
|
||||
end ;
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Condition_Block set model=__model;
|
||||
execute 'update staging2.IHTBT30_BT30_Test_Condition_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT30_BT30_Test_Condition_Block');
|
||||
|
||||
/*block starts - IHTBT30_BT30_Footer_block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT30_BT30_Footer_block',__file_mnemonic,__file_sheet_mnemonic,9);
|
||||
err_block:='IHTBT30_BT30_Footer_block';
|
||||
|
||||
insert into staging2.IHTBT30_BT30_Footer_block(dummy_f) values ('dummy');
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Footer_block a
|
||||
set prepared_by=( select column6 from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where b.block_tag='IHTBT30_BT30_Footer'
|
||||
and lower(column3)='prepared by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT30_BT30_Footer_block a
|
||||
set reviewed_by=( select column6 from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where b.block_tag='IHTBT30_BT30_Footer'
|
||||
and lower(column3)='reviewed by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT30_BT30_Footer_block a
|
||||
set approved_by=( select column6 from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where b.block_tag='IHTBT30_BT30_Footer'
|
||||
and lower(column3)='Approved by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT30_BT30_Footer_block a
|
||||
set comments=( select column3 from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where b.block_tag='IHTBT30_BT30_Footer'
|
||||
and block_row_number=5 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT30_BT30_Footer_block a
|
||||
set rev1=( select column3 from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where b.block_tag='IHTBT30_BT30_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Footer_block a
|
||||
set rev2=( select column7 from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where b.block_tag='IHTBT30_BT30_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT30_BT30_Footer_block a
|
||||
set rev3=( select column10 from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where b.block_tag='IHTBT30_BT30_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT30_BT30_Footer_block a
|
||||
set replaces=( select column11 from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where b.block_tag='IHTBT30_BT30_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT30_BT30_Footer_block a
|
||||
set revision_no=( select column11 from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where b.block_tag='IHTBT30_BT30_Footer'
|
||||
and block_row_number=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT30_BT30_Footer_block a
|
||||
set prepared_date=( select column10 from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where b.block_tag='IHTBT30_BT30_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT30_BT30_Footer_block a
|
||||
set reviewed_date=( select column10 from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where b.block_tag='IHTBT30_BT30_Footer'
|
||||
and block_row_number=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT30_BT30_Footer_block a
|
||||
set approved_date=( select column10 from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where b.block_tag='IHTBT30_BT30_Footer'
|
||||
and block_row_number=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT30_BT30_Footer_block set model=__model;
|
||||
execute 'update staging2.IHTBT30_BT30_Footer_block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT30_BT30_Footer_block');
|
||||
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'stg2', 'fn_IHTBT30_BT30_block', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
460
onetime/dataloadfunctions/IHT/IHTBT50_BT50_ODS.sql
Executable file
460
onetime/dataloadfunctions/IHT/IHTBT50_BT50_ODS.sql
Executable file
@@ -0,0 +1,460 @@
|
||||
drop function if exists staging2.fn_IHTBT50_BT50_TRX;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTBT50_BT50_TRX(p_client_id int,p_function_id int, p_file_mnemonic text,
|
||||
p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __test_instance_id int;
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare _error int;
|
||||
declare __test_master_id int;
|
||||
declare __test_instance_tractor_id int;
|
||||
begin
|
||||
__file_syspk := p_file_syspk;
|
||||
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTBT50_BT50_TRX
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHT
|
||||
Sheet Format: IHTBT50_BT50
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTBT50_BT50_TRX()
|
||||
***************************************************************/
|
||||
|
||||
insert into transactional.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
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,
|
||||
objective_of_test,
|
||||
test_condition,
|
||||
test_standard_desc,
|
||||
test_standard_id,
|
||||
acceptance_criteria,
|
||||
remarks,
|
||||
observations
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
Test_Request_no,
|
||||
sample_receipt_date::date,
|
||||
Test_report_No,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date::date,
|
||||
No_of_Sample,
|
||||
Test_Start_Date::date,
|
||||
Test_End_Date::date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Ref,
|
||||
test_location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
condition,
|
||||
test_standard,
|
||||
test_standard_id::numeric,
|
||||
acceptance_criteria,
|
||||
remarks,
|
||||
observations
|
||||
from
|
||||
staging2.IHTBT50_BT50_H1_block where trx_record =1;
|
||||
|
||||
update transactional.test_instance a
|
||||
set
|
||||
report_prepared_date=to_date(b.prepared_date,'DD-MM-YYYY'),
|
||||
report_reviewed_date=to_date(b.reviewed_date,'DD-MM-YYYY'),
|
||||
report_approved_date=to_date(b.approved_date,'DD-MM-YYYY'),
|
||||
report_prepared_by=b.prepared_by,
|
||||
report_reviewed_by=b.reviewed_by,
|
||||
report_approved_by=b.approved_by,
|
||||
report_template_replaces=b.replaces,
|
||||
report_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from staging2.IHTBT50_BT50_footer_block b
|
||||
where a.file_sheet_mnemonic='IHTBT50_BT50' and trx_record =1;
|
||||
|
||||
|
||||
|
||||
insert into transactional.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tyre_type,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
tyre_ply_rating,
|
||||
tyre_use_type,
|
||||
tyre_pressure_kg_per_cm2
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
tyre_details,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
ply_rating::numeric,
|
||||
tyre_use_type,
|
||||
pressure_kg_cm2::numeric
|
||||
from staging2.IHTBT50_BT50_tyre_details_block where trx_record =1;
|
||||
|
||||
|
||||
insert into transactional.test_instance_drawbar_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
weight_front_kg,
|
||||
weight_rear_kg,
|
||||
weight_total_kg
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
test_condition,
|
||||
front::numeric ,
|
||||
rear::numeric ,
|
||||
total::numeric
|
||||
from staging2.IHTBT50_BT50_weight_block where trx_record =1;
|
||||
|
||||
|
||||
/*block */
|
||||
|
||||
insert into transactional.test_instance_tractor_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tractor_platform
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
platform
|
||||
from staging2.IHTBT50_BT50_h1_block where trx_record =1;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set mahindra_model_yn = (
|
||||
case when lower(tractor_make) like 'mahindra%' then 'Y' else 'N' end
|
||||
) where file_syspk =__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info a
|
||||
set test_tractor_yn ='Y' where syspk in
|
||||
(select min(syspk) from transactional.test_instance_tractor_info b
|
||||
where b.file_syspk =a.file_syspk)
|
||||
and a.file_syspk =__file_syspk;
|
||||
|
||||
|
||||
|
||||
insert into transactional.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
observation,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column10
|
||||
from staging2.IHTBT50_BT50_test_res_1_block where trx_record =1;
|
||||
|
||||
insert into transactional.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
observation,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column10
|
||||
from staging2.IHTBT50_BT50_test_res_2_block where trx_record =1;
|
||||
|
||||
insert into transactional.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
observation,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column10
|
||||
from staging2.IHTBT50_BT50_test_res_3_block where trx_record =1;
|
||||
|
||||
insert into transactional.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
observation,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column10
|
||||
from staging2.IHTBT50_BT50_test_res_4_block where trx_record =1;
|
||||
|
||||
insert into transactional.iht_brake_perf_test_condition
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
date_of_test,
|
||||
time_of_test,
|
||||
location_name,
|
||||
test_mode,
|
||||
wind_velocity_kmph,
|
||||
ambient_temp_c,
|
||||
humidity_rh_pct
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,
|
||||
model,
|
||||
condition,
|
||||
date::date,
|
||||
time,
|
||||
location,
|
||||
mode,
|
||||
wind_velocity_km_hr,
|
||||
ambient_temperature_c::numeric ,
|
||||
humidity_rh::numeric
|
||||
from staging2.IHTBT50_BT50_test_condition_block where trx_record =1;
|
||||
|
||||
update transactional.iht_brake_perf_test_results a
|
||||
set brake_perf_test_condition_id=(select syspk
|
||||
from transactional.iht_brake_perf_test_condition b
|
||||
where a.test_mode =b.test_mode and a.test_condition=b.test_condition and a.file_syspk=b.file_syspk)
|
||||
where a.file_syspk=__file_syspk;
|
||||
|
||||
|
||||
select syspk into __test_instance_id from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_model into __model from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_make into __make from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select syspk from transactional.test_master into __test_master_id where test_type ='In House';
|
||||
select syspk into __test_instance_tractor_id from transactional.test_instance_tractor_info where file_syspk =__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance
|
||||
set test_master_id =__test_master_id,
|
||||
test_tractor_id =__test_instance_tractor_id
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.test_instance_drawbar_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.iht_brake_perf_test_condition
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.iht_brake_perf_test_results
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'trx', 'fn_IHTBT50_BT50_TRX', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
908
onetime/dataloadfunctions/IHT/IHTBT50_BT50_STG2.sql
Executable file
908
onetime/dataloadfunctions/IHT/IHTBT50_BT50_STG2.sql
Executable file
@@ -0,0 +1,908 @@
|
||||
drop function if exists staging2.fn_IHTBT50_BT50_block;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTBT50_BT50_block(p_client_id int,p_function_id int, p_file_mnemonic text,p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare err_query int;
|
||||
declare err_block text;
|
||||
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTBT50_BT50_block
|
||||
Function Desc: This function populates data into staging 2 block
|
||||
File Format: IHT
|
||||
Sheet Format: IHTBT50_BT50
|
||||
Creation Date: March 25 2021
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTBT50_BT50_block(p_client_id,p_function_id, p_file_mnemonic,
|
||||
p_file_sheet_mnemonic, p_file_syspk)
|
||||
Function call ex: select staging2.fn_IHTBT50_BT50_block(1,2,'IHT','IHTBT50_BT50',456)
|
||||
***************************************************************/
|
||||
|
||||
|
||||
SET search_path TO staging2;
|
||||
|
||||
/* to process multiple files - re-runnability*/
|
||||
|
||||
truncate table staging2.IHTBT50_BT50_H1_INT;
|
||||
truncate table staging2.IHTBT50_BT50_H1_block;
|
||||
truncate table staging2.IHTBT50_BT50_Weight_Tyre_Int;
|
||||
truncate table staging2.IHTBT50_BT50_Weight_Block;
|
||||
truncate table staging2.IHTBT50_BT50_Tyre_Details_Block;
|
||||
truncate table staging2.IHTBT50_BT50_Test_Res_1_Block;
|
||||
truncate table staging2.IHTBT50_BT50_Test_Res_2_Block;
|
||||
truncate table staging2.IHTBT50_BT50_Test_Res_3_Block;
|
||||
truncate table staging2.IHTBT50_BT50_Test_Res_4_Block;
|
||||
truncate table staging2.IHTBT50_BT50_Test_Condition_Block;
|
||||
truncate table staging2.IHTBT50_BT50_Footer_Block;
|
||||
truncate table staging2.stg_specific_table_IHTBT50_BT50;
|
||||
truncate table staging2.stg_process_table_IHTBT50_BT50;
|
||||
|
||||
|
||||
execute 'delete from fw_core.fw_jobctl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=null,
|
||||
row_previous_number=null,
|
||||
row_read_end=null,
|
||||
run_time=null
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* transfer data from generic to specific for IHT */
|
||||
execute 'insert into staging2.stg_specific_table_IHTBT50_BT50
|
||||
select * from staging1.staging_generic_table a
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''
|
||||
and a.file_syspk='||p_file_syspk||'';
|
||||
|
||||
select count(*) into err_query from staging2.stg_specific_table_IHTBT50_BT50;
|
||||
|
||||
if err_query=0 then
|
||||
err_context := 'data not present';
|
||||
raise exception using
|
||||
message = 'No Data for IHTBT50',
|
||||
detail = 'No data in table stg_specific_table_IHTBT50_BT50',
|
||||
errcode = '42704',
|
||||
hint = 'check sheet mnemonic in generic table, if it is null update it';
|
||||
end if;
|
||||
|
||||
/* trimming data */
|
||||
update staging2.stg_specific_table_IHTBT50_BT50
|
||||
set column10='Objective' where lower(column10) like 'objective%';
|
||||
|
||||
update staging2.stg_specific_table_IHTBT50_BT50
|
||||
set column10='Acceptance criteria' where lower(column10) like 'acceptance criteria%';
|
||||
|
||||
|
||||
update staging2.stg_specific_table_IHTBT50_BT50
|
||||
set column10='Condition' where lower(column10) like 'condition%';
|
||||
|
||||
update transactional.source_config set F1_source=F1_modified ;
|
||||
|
||||
|
||||
/* keyword match in config table*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=(select min(b.row_number)
|
||||
from staging2.stg_specific_table_IHTBT50_BT50 b
|
||||
where upper(F1_modified)=upper(column3)
|
||||
and b.is_rownumber_fetched is null)
|
||||
where a.row_number_start is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* reverese update in process table for match*/
|
||||
execute 'update staging2.stg_specific_table_IHTBT50_BT50 a
|
||||
set is_rownumber_fetched=1
|
||||
from transactional.source_config b
|
||||
where upper(F1_modified)=upper(column3)
|
||||
and b.row_number_start=a.row_number
|
||||
and is_rownumber_fetched is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'update transactional.source_config a set row_previous_number=row_number_start-1
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* update config files for row numbers start, end */
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end= (select b.row_number_start
|
||||
from transactional.source_config b
|
||||
where b.syspk=a.syspk+1 and file_mnemonic='''||p_file_mnemonic||''' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||''' )
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* config file last field update as null otherwise it picks up next format row number*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end = null ,run_time=current_timestamp
|
||||
where f1_modified =''Prepared by''
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* tagging block_row_numbers*/
|
||||
execute 'insert into staging2.stg_process_table_IHTBT50_BT50
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTBT50_BT50 a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Test Request No''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTBT50_BT50
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTBT50_BT50 a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Un-Ballast cold''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTBT50_BT50
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTBT50_BT50 a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Ballast cold''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTBT50_BT50
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTBT50_BT50 a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Fade Performance''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTBT50_BT50
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTBT50_BT50 a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Recovery Performance''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTBT50_BT50
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTBT50_BT50 a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Weight (kg)''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTBT50_BT50
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTBT50_BT50 a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Prepared by''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/*selecting tractor model*/
|
||||
select column5 into __model from staging2.stg_process_table_IHTBT50_BT50 a
|
||||
where block_tag='IHTBT50_BT50_H1' and trim(column3)='Tractor Model';
|
||||
|
||||
/*block starts - IHTBT50_BT50_H1_BLOCK */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT50_BT50_H1_BLOCK',__file_mnemonic,__file_sheet_mnemonic,1);
|
||||
err_block:='IHTBT50_BT50_H1_BLOCK';
|
||||
insert into staging2.IHTBT50_BT50_H1_INT (c1,c2)
|
||||
select a.column3,column5 from staging2.stg_process_table_IHTBT50_BT50 a where block_tag='IHTBT50_BT50_H1'
|
||||
and block_row_number <=9;
|
||||
|
||||
insert into staging2.IHTBT50_BT50_H1_INT (c1,c2)
|
||||
select a.column7,column9 from staging2.stg_process_table_IHTBT50_BT50 a where block_tag='IHTBT50_BT50_H1'
|
||||
and block_row_number <=9;
|
||||
|
||||
insert into staging2.IHTBT50_BT50_H1_INT (c1,c2)
|
||||
select 'Objective',column10
|
||||
from staging2.stg_process_table_IHTBT50_BT50 a
|
||||
where block_tag='IHTBT50_BT50_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTBT50_BT50 a
|
||||
where column10='Objective'
|
||||
and block_tag='IHTBT50_BT50_H1'
|
||||
);
|
||||
|
||||
insert into staging2.IHTBT50_BT50_H1_INT (c1,c2)
|
||||
select 'Acceptance criteria',column8
|
||||
from staging2.stg_process_table_IHTBT50_BT50 a
|
||||
where block_tag='IHTBT50_BT50_H1' and block_row_number=11;
|
||||
|
||||
|
||||
insert into staging2.IHTBT50_BT50_H1_INT (c1,c2)
|
||||
select 'Condition',column10
|
||||
from staging2.stg_process_table_IHTBT50_BT50 a
|
||||
where block_tag='IHTBT50_BT50_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTBT50_BT50 a
|
||||
where column10='Condition'
|
||||
and block_tag='IHTBT50_BT50_H1'
|
||||
);
|
||||
|
||||
|
||||
|
||||
insert into staging2.IHTBT50_BT50_H1_INT (c1,c2)
|
||||
select 'Test std',column4
|
||||
from staging2.stg_process_table_IHTBT50_BT50 b
|
||||
where block_row_number=11
|
||||
and block_tag='IHTBT50_BT50_H1';
|
||||
|
||||
insert into staging2.IHTBT50_BT50_H1_INT (c1,c2)
|
||||
select 'Test std Id',column3
|
||||
from staging2.stg_process_table_IHTBT50_BT50 b
|
||||
where block_row_number=11
|
||||
and block_tag='IHTBT50_BT50_H1';
|
||||
|
||||
insert into staging2.IHTBT50_BT50_H1_INT (c1,c2)
|
||||
select 'Test Standard ref',split_part(column3,':',2)
|
||||
from staging2.stg_process_table_IHTBT50_BT50 b
|
||||
where block_row_number=10
|
||||
and block_tag='IHTBT50_BT50_H1';
|
||||
|
||||
|
||||
insert into staging2.IHTBT50_BT50_H1_INT (c1,c2)
|
||||
select 'Observations',column3
|
||||
from staging2.stg_process_table_IHTBT50_BT50
|
||||
where block_tag='IHTBT50_BT50_Weight_Tyre'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTBT50_BT50 a
|
||||
where column3='Remarks & Observations'
|
||||
and block_tag='IHTBT50_BT50_Weight_Tyre'
|
||||
);
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_H1_Int set model=__model;
|
||||
execute 'update staging2.IHTBT50_BT50_H1_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
insert into staging2.IHTBT50_BT50_H1_Block
|
||||
(
|
||||
dummy_f,
|
||||
Test_Request_no,
|
||||
Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Tractor_Model,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date,
|
||||
Test_Location,
|
||||
No_of_Sample,
|
||||
Test_Start_Date,
|
||||
Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Domestic_Export,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Platform,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
condition,
|
||||
Test_Standard,
|
||||
Test_Standard_id,
|
||||
Test_Standard_ref,
|
||||
Remarks,
|
||||
Observations
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{c2}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[c2::text]) AS val
|
||||
FROM staging2.IHTBT50_BT50_H1_INT
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,
|
||||
a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,
|
||||
a_18 text,a_19 text,a_20 text,a_21 text,a_22 text,a_23 text,a_24 text,a_25 text,a_26 text);
|
||||
|
||||
update staging2.IHTBT50_BT50_H1_Block
|
||||
set Sample_Receipt_Date=case
|
||||
when Sample_Receipt_Date like '%-%' then Sample_Receipt_Date::timestamptz
|
||||
else date '1899-12-30' + Sample_Receipt_Date::int * interval '1' day
|
||||
end;
|
||||
|
||||
update staging2.IHTBT50_BT50_H1_Block
|
||||
set Test_Report_Date=case
|
||||
when Test_Report_Date like '%-%' then Test_Report_Date::timestamptz
|
||||
else date '1899-12-30' + Test_Report_Date::int * interval '1' day
|
||||
end;
|
||||
|
||||
update staging2.IHTBT50_BT50_H1_Block
|
||||
set Test_Start_Date=case
|
||||
when Test_Report_Date like '%-%' then Test_Report_Date::timestamptz
|
||||
else date '1899-12-30' + Test_Report_Date::int * interval '1' day
|
||||
end;
|
||||
update staging2.IHTBT50_BT50_H1_Block
|
||||
set Test_End_Date=case
|
||||
when Test_Report_Date like '%-%' then Test_Report_Date::timestamptz
|
||||
else date '1899-12-30' + Test_Report_Date::int * interval '1' day
|
||||
end;
|
||||
|
||||
delete from staging2.IHTBT50_BT50_H1_Block where dummy_f is null ;
|
||||
update staging2.IHTBT50_BT50_H1_Block set model=__model;
|
||||
execute 'update staging2.IHTBT50_BT50_H1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT50_BT50_H1_BLOCK');
|
||||
|
||||
|
||||
insert into staging2.IHTBT50_BT50_Weight_Tyre_Int
|
||||
(
|
||||
column3,column4,column5,column6,column7,column8,column9,
|
||||
column10,column11,column12,block_row_number
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column7,column8,
|
||||
column9,column10,column11,column12,block_row_number
|
||||
from staging2.stg_process_table_IHTBT50_BT50 a
|
||||
where block_tag='IHTBT50_BT50_Weight_Tyre'
|
||||
order by block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Weight_Tyre_Int set model=__model;
|
||||
execute 'update staging2.IHTBT50_BT50_Weight_Tyre_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
/*block starts - IHTBT50_BT50_Weight_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT50_BT50_Weight_Block',__file_mnemonic,__file_sheet_mnemonic,2);
|
||||
err_block:='IHTBT50_BT50_Weight_Block';
|
||||
insert into staging2.IHTBT50_BT50_Weight_Block
|
||||
(
|
||||
dummy_f,
|
||||
test_condition,
|
||||
Front,
|
||||
Rear,
|
||||
Total
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column5,column7}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column5::text,column7::text]) AS val
|
||||
FROM staging2.IHTBT50_BT50_Weight_Tyre_Int where column5 is not null and column7 is not null and block_row_number<>1
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text);
|
||||
|
||||
|
||||
delete from staging2.IHTBT50_BT50_Weight_Block where dummy_f is null ;
|
||||
update staging2.IHTBT50_BT50_Weight_Block set model=__model;
|
||||
execute 'update staging2.IHTBT50_BT50_Weight_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT50_BT50_Weight_Block');
|
||||
|
||||
/*block starts - IHTBT50_BT50_Tyre_Details_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT50_BT50_Tyre_Details_Block',__file_mnemonic,__file_sheet_mnemonic,3);
|
||||
err_block:='IHTBT50_BT50_Tyre_Details_Block';
|
||||
insert into staging2.IHTBT50_BT50_Tyre_Details_Block
|
||||
(
|
||||
dummy_f,
|
||||
Tyre_Details,
|
||||
Pressure_kg_cm2,
|
||||
tyre_use_type,
|
||||
Tyre_Make,
|
||||
tyre_size,
|
||||
ply_rating
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column10,column11}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column10::text,column11::text]) AS val
|
||||
FROM staging2.IHTBT50_BT50_Weight_Tyre_Int where column11 is not null or column10 is not null
|
||||
ORDER BY generate_series(1,15),block_row_number,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text);
|
||||
|
||||
|
||||
|
||||
delete from staging2.IHTBT50_BT50_Tyre_Details_Block where dummy_f is null ;
|
||||
update staging2.IHTBT50_BT50_Tyre_Details_Block set model=__model;
|
||||
execute 'update staging2.IHTBT50_BT50_Tyre_Details_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT50_BT50_Tyre_Details_Block');
|
||||
|
||||
|
||||
/*block starts - IHTBT50_BT50_Test_Res_1_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT50_BT50_Test_Res_1_Block',__file_mnemonic,__file_sheet_mnemonic,4);
|
||||
err_block:='IHTBT50_BT50_Test_Res_1_Block';
|
||||
|
||||
insert into staging2.IHTBT50_BT50_Test_Res_1_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
from staging2.stg_process_table_IHTBT50_BT50 a
|
||||
where block_tag='IHTBT50_BT50_Test_Res_1'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_1_Block
|
||||
set column2=column3 where block_row_number=1;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_1_Block a
|
||||
set column2= b.first_value from (SELECT
|
||||
block_row_number,column2, value_partition, first_value(column2) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column2,
|
||||
sum(case when column2 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT50_BT50_Test_Res_1_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_1_Block a
|
||||
set column10= b.first_value from (SELECT
|
||||
block_row_number,column10, value_partition, first_value(column10) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column10,
|
||||
sum(case when column10 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT50_BT50_Test_Res_1_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_1_Block set trx_record =0 where block_row_number in (1,2,3,4);
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_1_Block set trx_record =0 where
|
||||
column4 is null and column5 is null;
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_1_Block set model=__model;
|
||||
execute 'update staging2.IHTBT50_BT50_Test_Res_1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT50_BT50_Test_Res_1_Block');
|
||||
|
||||
|
||||
/*block starts - IHTBT50_BT50_Test_Res_2_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT50_BT50_Test_Res_2_Block',__file_mnemonic,__file_sheet_mnemonic,5);
|
||||
err_block:='IHTBT50_BT50_Test_Res_2_Block';
|
||||
|
||||
insert into staging2.IHTBT50_BT50_Test_Res_2_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
from staging2.stg_process_table_IHTBT50_BT50 a
|
||||
where block_tag='IHTBT50_BT50_Test_Res_2'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_2_Block
|
||||
set column2=column3 where block_row_number=1;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_2_Block a
|
||||
set column2= b.first_value from (SELECT
|
||||
block_row_number,column2, value_partition, first_value(column2) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
select
|
||||
block_row_number,
|
||||
column2,
|
||||
sum(case when column2 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT50_BT50_Test_Res_2_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_2_Block a
|
||||
set column10= b.first_value from (SELECT
|
||||
block_row_number,column10, value_partition, first_value(column10) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column10,
|
||||
sum(case when column10 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT50_BT50_Test_Res_2_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_2_Block set trx_record =0 where block_row_number in (1,2,3,4);
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_2_Block set trx_record =0 where
|
||||
column4 is null and column5 is null;
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_2_Block set model=__model;
|
||||
execute 'update staging2.IHTBT50_BT50_Test_Res_2_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT50_BT50_Test_Res_2_Block');
|
||||
|
||||
|
||||
/*block starts - IHTBT50_BT50_Test_Res_3_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT50_BT50_Test_Res_3_Block',__file_mnemonic,__file_sheet_mnemonic,6);
|
||||
err_block:='IHTBT50_BT50_Test_Res_3_Block';
|
||||
|
||||
insert into staging2.IHTBT50_BT50_Test_Res_3_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
from staging2.stg_process_table_IHTBT50_BT50 a
|
||||
where block_tag='IHTBT50_BT50_Test_Res_3'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_3_Block
|
||||
set column2=column3 where block_row_number=1;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_3_Block a
|
||||
set column2= b.first_value from (SELECT
|
||||
block_row_number,column2, value_partition, first_value(column2) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column2,
|
||||
sum(case when column2 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT50_BT50_Test_Res_3_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_3_Block a
|
||||
set column10= b.first_value from (SELECT
|
||||
block_row_number,column10, value_partition, first_value(column10) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column10,
|
||||
sum(case when column10 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT50_BT50_Test_Res_3_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_3_Block set trx_record =0 where block_row_number in (1,2,3,4);
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_3_Block set trx_record =0 where
|
||||
column4 is null and column5 is null;
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_3_Block set model=__model;
|
||||
execute 'update staging2.IHTBT50_BT50_Test_Res_3_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT50_BT50_Test_Res_3_Block');
|
||||
|
||||
|
||||
/*block starts - IHTBT50_BT50_Test_Res_4_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT50_BT50_Test_Res_4_Block',__file_mnemonic,__file_sheet_mnemonic,7);
|
||||
err_block:='IHTBT50_BT50_Test_Res_4_Block';
|
||||
|
||||
insert into staging2.IHTBT50_BT50_Test_Res_4_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,block_row_number
|
||||
from staging2.stg_process_table_IHTBT50_BT50 a
|
||||
where block_tag='IHTBT50_BT50_Test_Res_4'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_4_Block
|
||||
set column2=column3 where block_row_number=1;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_4_Block a
|
||||
set column2= b.first_value from (SELECT
|
||||
block_row_number,column2, value_partition, first_value(column2) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column2,
|
||||
sum(case when column2 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT50_BT50_Test_Res_4_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_4_Block a
|
||||
set column10= b.first_value from (SELECT
|
||||
block_row_number,column10, value_partition, first_value(column10) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column10,
|
||||
sum(case when column10 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT50_BT50_Test_Res_4_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_4_Block set trx_record =0 where block_row_number in (1,2,3,4,15);
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_4_Block set trx_record =0 where
|
||||
column4 is null and column5 is null;
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Res_4_Block set model=__model;
|
||||
execute 'update staging2.IHTBT50_BT50_Test_Res_4_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT50_BT50_Test_Res_4_Block');
|
||||
|
||||
|
||||
/*block starts - IHTBT50_BT50_Test_Condition_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT50_BT50_Test_Condition_Block',__file_mnemonic,__file_sheet_mnemonic,8);
|
||||
err_block:='IHTBT50_BT50_Test_Condition_Block';
|
||||
|
||||
|
||||
insert into staging2.IHTBT50_BT50_Test_Condition_Block (condition)
|
||||
select column2 from staging2.IHTBT50_BT50_Test_Res_1_Block
|
||||
where block_row_number=2
|
||||
union
|
||||
select column2 from staging2.IHTBT50_BT50_Test_Res_2_Block
|
||||
where block_row_number=2
|
||||
union
|
||||
select column2 from staging2.IHTBT50_BT50_Test_Res_3_Block
|
||||
where block_row_number=2
|
||||
union
|
||||
select column2 from staging2.IHTBT50_BT50_Test_Res_4_Block
|
||||
where block_row_number=2;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Condition_Block
|
||||
set date=b.column4,
|
||||
location=b.column7,
|
||||
--time=b.column9,
|
||||
mode=b.column10
|
||||
from staging2.IHTBT50_BT50_Test_Res_1_Block b
|
||||
where b.block_row_number =2 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Condition_Block
|
||||
set Wind_Velocity_Km_hr=b.column5,
|
||||
Ambient_Temperature_C=b.column7,
|
||||
Humidity_RH=b.column9
|
||||
from staging2.IHTBT50_BT50_Test_Res_1_Block b
|
||||
where b.block_row_number =3 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Condition_Block
|
||||
set date=b.column4,
|
||||
location=b.column7,
|
||||
--time=b.column9,
|
||||
mode=b.column10
|
||||
from staging2.IHTBT50_BT50_Test_Res_2_Block b
|
||||
where b.block_row_number =2 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Condition_Block
|
||||
set Wind_Velocity_Km_hr=b.column5,
|
||||
Ambient_Temperature_C=b.column7,
|
||||
Humidity_RH=b.column9
|
||||
from staging2.IHTBT50_BT50_Test_Res_2_Block b
|
||||
where b.block_row_number =3 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Condition_Block
|
||||
set date=b.column4,
|
||||
location=b.column7,
|
||||
--time=b.column9,
|
||||
mode=b.column10
|
||||
from staging2.IHTBT50_BT50_Test_Res_3_Block b
|
||||
where b.block_row_number =2 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Condition_Block
|
||||
set Wind_Velocity_Km_hr=b.column5,
|
||||
Ambient_Temperature_C=b.column7,
|
||||
Humidity_RH=b.column9
|
||||
from staging2.IHTBT50_BT50_Test_Res_3_Block b
|
||||
where b.block_row_number =3 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Condition_Block
|
||||
set date=b.column4,
|
||||
location=b.column7,
|
||||
--time=b.column9,
|
||||
mode=b.column10
|
||||
from staging2.IHTBT50_BT50_Test_Res_4_Block b
|
||||
where b.block_row_number =2 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Condition_Block
|
||||
set Wind_Velocity_Km_hr=b.column5,
|
||||
Ambient_Temperature_C=b.column7,
|
||||
Humidity_RH=b.column9
|
||||
from staging2.IHTBT50_BT50_Test_Res_4_Block b
|
||||
where b.block_row_number=3 and condition=b.column2;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Condition_Block a
|
||||
set date= case
|
||||
when date like '%-%' then date::timestamptz
|
||||
else date '1899-12-30' + date::int * interval '1' day
|
||||
end ;
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Test_Condition_Block set model=__model;
|
||||
execute 'update staging2.IHTBT50_BT50_Test_Condition_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT50_BT50_Test_Condition_Block');
|
||||
|
||||
/*block starts - IHTBT50_BT50_Footer_block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTBT50_BT50_Footer_block',__file_mnemonic,__file_sheet_mnemonic,9);
|
||||
err_block:='IHTBT50_BT50_Footer_block';
|
||||
|
||||
insert into staging2.IHTBT50_BT50_Footer_block(dummy_f) values ('dummy');
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Footer_block a
|
||||
set prepared_by=( select column6 from staging2.stg_process_table_IHTBT50_BT50 b
|
||||
where b.block_tag='IHTBT50_BT50_Footer'
|
||||
and lower(column3)='prepared by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT50_BT50_Footer_block a
|
||||
set reviewed_by=( select column6 from staging2.stg_process_table_IHTBT50_BT50 b
|
||||
where b.block_tag='IHTBT50_BT50_Footer'
|
||||
and lower(column3)='reviewed by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT50_BT50_Footer_block a
|
||||
set approved_by=( select column6 from staging2.stg_process_table_IHTBT50_BT50 b
|
||||
where b.block_tag='IHTBT50_BT50_Footer'
|
||||
and lower(column3)='approved by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT50_BT50_Footer_block a
|
||||
set comments=( select column3 from staging2.stg_process_table_IHTBT50_BT50 b
|
||||
where b.block_tag='IHTBT50_BT50_Footer'
|
||||
and block_row_number=5 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT50_BT50_Footer_block a
|
||||
set rev1=( select column3 from staging2.stg_process_table_IHTBT50_BT50 b
|
||||
where b.block_tag='IHTBT50_BT50_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
update staging2.IHTBT50_BT50_Footer_block a
|
||||
set rev2=( select column7 from staging2.stg_process_table_IHTBT50_BT50 b
|
||||
where b.block_tag='IHTBT50_BT50_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT50_BT50_Footer_block a
|
||||
set rev3=( select column10 from staging2.stg_process_table_IHTBT50_BT50 b
|
||||
where b.block_tag='IHTBT50_BT50_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT50_BT50_Footer_block a
|
||||
set replaces=( select column11 from staging2.stg_process_table_IHTBT50_BT50 b
|
||||
where b.block_tag='IHTBT50_BT50_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT50_BT50_Footer_block a
|
||||
set revision_no=( select column11 from staging2.stg_process_table_IHTBT50_BT50 b
|
||||
where b.block_tag='IHTBT50_BT50_Footer'
|
||||
and block_row_number=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT50_BT50_Footer_block a
|
||||
set prepared_date=( select column10 from staging2.stg_process_table_IHTBT50_BT50 b
|
||||
where b.block_tag='IHTBT50_BT50_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT50_BT50_Footer_block a
|
||||
set reviewed_date=( select column10 from staging2.stg_process_table_IHTBT50_BT50 b
|
||||
where b.block_tag='IHTBT50_BT50_Footer'
|
||||
and block_row_number=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT50_BT50_Footer_block a
|
||||
set approved_date=( select column10 from staging2.stg_process_table_IHTBT50_BT50 b
|
||||
where b.block_tag='IHTBT50_BT50_Footer'
|
||||
and block_row_number=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTBT50_BT50_Footer_block set model=__model;
|
||||
execute 'update staging2.IHTBT50_BT50_Footer_block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTBT50_BT50_Footer_block');
|
||||
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'stg2', 'fn_IHTBT50_BT50_block', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
539
onetime/dataloadfunctions/IHT/IHTBTD_BTD_ODS.sql
Executable file
539
onetime/dataloadfunctions/IHT/IHTBTD_BTD_ODS.sql
Executable file
@@ -0,0 +1,539 @@
|
||||
drop function if exists staging2.fn_IHTBTD_BTD_TRX;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTBTD_BTD_TRX(p_client_id int,p_function_id int, p_file_mnemonic text,
|
||||
p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __test_instance_id int;
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare _error int;
|
||||
declare __test_master_id int;
|
||||
declare __test_instance_tractor_id int;
|
||||
begin
|
||||
__file_syspk := p_file_syspk;
|
||||
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTBTD_BTD_TRX
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHT
|
||||
Sheet Format: IHTBTD_BTD
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTBTD_BTD_TRX()
|
||||
***************************************************************/
|
||||
insert into transactional.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
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,
|
||||
objective_of_test,
|
||||
test_condition,
|
||||
test_standard_desc,
|
||||
test_standard_id,
|
||||
acceptance_criteria,
|
||||
remarks,
|
||||
observations
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
Test_Request_no,
|
||||
to_date(sample_receipt_date,'DD-MM-YYYY'),
|
||||
Test_report_No,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
to_date(Test_Report_Date,'DD-MM-YYYY'),
|
||||
No_of_Sample,
|
||||
to_date(Test_Start_Date,'DD-MM-YYYY'),
|
||||
to_date(Test_End_Date, 'DD-MM-YYYY'),
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
test_location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
condition,
|
||||
test_standard,
|
||||
test_standard_id::numeric,
|
||||
test_standard_ref
|
||||
acceptance_criteria,
|
||||
remarks,
|
||||
observations
|
||||
from
|
||||
staging2.IHTBTD_BTD_H1_block where trx_record =1;
|
||||
|
||||
update transactional.test_instance a
|
||||
set
|
||||
report_prepared_date=to_date(b.prepared_date,'DD-MM-YYYY'),
|
||||
report_reviewed_date=to_date(b.reviewed_date,'DD-MM-YYYY'),
|
||||
report_approved_date=to_date(b.approved_date,'DD-MM-YYYY'),
|
||||
report_prepared_by=b.prepared_by,
|
||||
report_reviewed_by=b.reviewed_by,
|
||||
report_approved_by=b.approved_by,
|
||||
report_template_replaces=b.replaces,
|
||||
report_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from staging2.IHTBTD_BTD_footer_block b
|
||||
where a.file_sheet_mnemonic='IHTBTD_BTD' and trx_record =1;
|
||||
|
||||
|
||||
|
||||
insert into transactional.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tyre_type,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
tyre_ply_rating,
|
||||
tyre_use_type,
|
||||
tyre_pressure_kg_per_cm2
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
tyre_details,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
ply_rating::numeric,
|
||||
tyre_use_type,
|
||||
pressure_kg_cm2::numeric
|
||||
from staging2.IHTBTD_BTD_tyre_details_block where trx_record =1;
|
||||
|
||||
|
||||
|
||||
insert into transactional.test_instance_drawbar_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
weight_front_kg,
|
||||
weight_rear_kg,
|
||||
weight_total_kg,
|
||||
status
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
test_condition,
|
||||
front::numeric ,
|
||||
rear::numeric ,
|
||||
total::numeric ,
|
||||
status
|
||||
from staging2.IHTBTD_BTD_weight_block where trx_record =1;
|
||||
|
||||
|
||||
/*block */
|
||||
|
||||
insert into transactional.test_instance_tractor_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tractor_platform
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
platform
|
||||
from staging2.IHTBTD_BTD_h1_block where trx_record =1;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set mahindra_model_yn = (
|
||||
case when tractor_make like 'Mahindra%' then 'Y' else 'N' end
|
||||
) where file_syspk =__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info a
|
||||
set test_tractor_yn ='Y' where syspk in
|
||||
(select min(syspk) from transactional.test_instance_tractor_info b
|
||||
where b.file_syspk =a.file_syspk)
|
||||
and a.file_syspk =__file_syspk;
|
||||
|
||||
|
||||
|
||||
insert into transactional.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
observation,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column11
|
||||
from staging2.IHTBTD_BTD_test_res_1_block where trx_record =1;
|
||||
|
||||
insert into transactional.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
observation,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column11
|
||||
from staging2.IHTBTD_BTD_test_res_2_block where trx_record =1;
|
||||
|
||||
insert into transactional.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
observation,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column11
|
||||
from staging2.IHTBTD_BTD_test_res_3_block where trx_record =1;
|
||||
|
||||
insert into transactional.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
observation,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column11
|
||||
from staging2.IHTBTD_BTD_test_res_4_block where trx_record =1;
|
||||
|
||||
insert into transactional.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
observation,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column11
|
||||
from staging2.IHTBTD_BTD_test_res_5_block where trx_record =1;
|
||||
|
||||
|
||||
insert into transactional.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
observation,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column13
|
||||
from staging2.IHTBTD_BTD_test_res_6_block where trx_record =1;
|
||||
|
||||
insert into transactional.iht_brake_perf_test_condition
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
date_of_test,
|
||||
time_of_test,
|
||||
location_name,
|
||||
test_mode,
|
||||
wind_velocity_kmph,
|
||||
ambient_temp_c,
|
||||
humidity_rh_pct
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,
|
||||
model,
|
||||
condition,
|
||||
date::date,
|
||||
time,
|
||||
location,
|
||||
mode,
|
||||
wind_velocity_km_hr,
|
||||
ambient_temperature_c::numeric ,
|
||||
humidity_rh::numeric
|
||||
from staging2.ihtbtd_btd_test_condition_block where trx_record =1;
|
||||
|
||||
update transactional.iht_brake_perf_test_results a
|
||||
set brake_perf_test_condition_id=(select syspk
|
||||
from transactional.iht_brake_perf_test_condition b
|
||||
where a.test_mode =b.test_mode and a.test_condition=b.test_condition and a.file_syspk=b.file_syspk)
|
||||
where a.file_syspk=__file_syspk;
|
||||
|
||||
|
||||
|
||||
select syspk into __test_instance_id from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_model into __model from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_make into __make from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select syspk from transactional.test_master into __test_master_id where test_type ='In House';
|
||||
select syspk into __test_instance_tractor_id from transactional.test_instance_tractor_info where file_syspk =__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance
|
||||
set test_master_id =__test_master_id,
|
||||
test_tractor_id =__test_instance_tractor_id
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.test_instance_drawbar_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.iht_brake_perf_test_condition
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.iht_brake_perf_test_results
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'trx', 'fn_IHTBTD_BTD_TRX', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
1098
onetime/dataloadfunctions/IHT/IHTBTD_BTD_STG2.sql
Executable file
1098
onetime/dataloadfunctions/IHT/IHTBTD_BTD_STG2.sql
Executable file
File diff suppressed because it is too large
Load Diff
336
onetime/dataloadfunctions/IHT/IHT_CGM_ODS.sql
Executable file
336
onetime/dataloadfunctions/IHT/IHT_CGM_ODS.sql
Executable file
@@ -0,0 +1,336 @@
|
||||
drop function if exists staging2.fn_IHTCGM_CGM_TRX;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTCGM_CGM_TRX(p_client_id int,p_function_id int, p_file_mnemonic text,
|
||||
p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __test_instance_id int;
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare _error int;
|
||||
declare __test_master_id int;
|
||||
declare __test_instance_tractor_id int;
|
||||
begin
|
||||
__file_syspk := p_file_syspk;
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTCGM_CGM_TRX
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHTCGM
|
||||
Sheet Format: IHTCGM_CGM
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTCGM_CGM_TRX()
|
||||
***************************************************************/
|
||||
insert into transactional.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
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,
|
||||
objective_of_test,
|
||||
acceptance_criteria,
|
||||
remarks
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
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,
|
||||
Remarks
|
||||
from staging2.IHTCGM_CGM_H1_block where trx_record=1;
|
||||
|
||||
update transactional.test_instance a
|
||||
set
|
||||
report_prepared_date=to_date(b.prepared_date,'DD-MM-YYYY'),
|
||||
report_reviewed_date=to_date(b.reviewed_date,'DD-MM-YYYY'),
|
||||
report_approved_date=to_date(b.approved_date,'DD-MM-YYYY'),
|
||||
report_prepared_by=b.prepared_by,
|
||||
report_reviewed_by=b.reviewed_by,
|
||||
report_approved_by=b.approved_by,
|
||||
report_template_replaces=b.replaces,
|
||||
report_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from staging2.IHTCGM_CGM_footer_block b
|
||||
where a.file_sheet_mnemonic ='IHTCGM_CGM' and trx_record=1;
|
||||
|
||||
insert into transactional.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tyre_type,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
tyre_ply_rating,
|
||||
tyre_load_carrying_capacity,
|
||||
tyre_pressure_kg_per_cm2,
|
||||
tyre_static_rolling_radius_mm,
|
||||
tyre_dynamic_rolling_radius_mm,
|
||||
tyre_wheel_rim_make_and_size
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
tyre_details,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
ply_rating::numeric,
|
||||
load_carrying_capacity,
|
||||
Pressure_kg_cm2::numeric ,
|
||||
Dynamic_rolling_radius::numeric ,
|
||||
Static_rolling_radius::numeric ,
|
||||
wheel_rim_make_size
|
||||
from staging2.IHTCGM_CGM_tyre_details_block where trx_record=1;
|
||||
|
||||
insert into transactional.test_instance_tractor_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
wheel_base_mm,
|
||||
rear_track_width_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
wheel_base::numeric ,
|
||||
rear_track_width::numeric
|
||||
from staging2.IHTCGM_CGM_wheel_block where trx_record=1;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set mahindra_model_yn = (
|
||||
case when tractor_make like 'Mahindra%' then 'Y' else 'N' end
|
||||
) where file_syspk =__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info a
|
||||
set test_tractor_yn ='Y' where syspk in
|
||||
(select min(syspk) from transactional.test_instance_tractor_info b
|
||||
where b.file_syspk =a.file_syspk)
|
||||
and a.file_syspk =__file_syspk;
|
||||
|
||||
/*block */
|
||||
|
||||
insert into transactional.test_instance_weight_reaction
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
total_weight_kg,
|
||||
front_reaction_kg,
|
||||
rear_reaction_kg,
|
||||
left_reaction_fl_rl_kg,
|
||||
right_reaction_fr_rr_kg,
|
||||
front_left_reaction_kg,
|
||||
front_right_reactionkg,
|
||||
rear_left_reaction_kg,
|
||||
rear_right_reactionkg,
|
||||
distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg::numeric,
|
||||
Front_Reaction_kg::numeric ,
|
||||
Rear_Reaction_kg::numeric ,
|
||||
Left_Reaction_FL_RL_kg::numeric ,
|
||||
Right_reaction_FR_RR_kg::numeric ,
|
||||
Front_Left_Reaction_kg::numeric ,
|
||||
Front_Right_Reaction_kg::numeric ,
|
||||
Rear_Left_Reaction_kg::numeric ,
|
||||
Rear_Right_Reaction_kg::numeric ,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1::numeric
|
||||
from staging2.IHTCGM_CGM_weight_block where trx_record=1;
|
||||
|
||||
|
||||
insert into transactional.IHT_cgm_lifting_angle_load_details
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
angle,
|
||||
value_in_tan,
|
||||
diff_of_tan_value,
|
||||
load_kn,
|
||||
load_kg,
|
||||
diff_in_load_kg,
|
||||
vertical_co_ordinate_z_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column3::numeric,
|
||||
column4::numeric ,
|
||||
column5::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9::numeric,
|
||||
column10::numeric
|
||||
from staging2.IHTCGM_cgm_lifting_block where trx_record=1;
|
||||
|
||||
insert into transactional.IHT_cgm_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
horizontal_distance_from_rac_x_mm,
|
||||
lateral_co_ordinate_in_horizontal_plane_y_mm,
|
||||
vertical_co_ordinate_z_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
determination_of_horizontal_distance_from_rac_x::numeric ,
|
||||
determination_of_lateral_coordinate_in_horizontal_plane_y::numeric ,
|
||||
determination_of_vertical_coordinate_z::numeric
|
||||
from staging2.IHTCGM_cgm_results_block where trx_record=1;
|
||||
|
||||
|
||||
|
||||
select syspk into __test_instance_id from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_model into __model from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_make into __make from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select syspk from transactional.test_master into __test_master_id where test_type ='In House';
|
||||
select syspk into __test_instance_tractor_id from transactional.test_instance_tractor_info where file_syspk =__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance
|
||||
set test_master_id =__test_master_id,
|
||||
test_tractor_id =__test_instance_tractor_id
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_weight_reaction
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.IHT_cgm_lifting_angle_load_details
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.IHT_cgm_results
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'trx', 'fn_IHTCGM_CGM_TRX', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
565
onetime/dataloadfunctions/IHT/IHT_CGM_STG2.sql
Executable file
565
onetime/dataloadfunctions/IHT/IHT_CGM_STG2.sql
Executable file
@@ -0,0 +1,565 @@
|
||||
drop function if exists staging2.fn_IHTCGM_CGM_block;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTCGM_CGM_block(p_client_id int,p_function_id int, p_file_mnemonic text,p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare err_query int;
|
||||
declare err_block text;
|
||||
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTCGM_CGM_block
|
||||
Function Desc: This function populates data into staging 2 block
|
||||
File Format: IHTCGM
|
||||
Sheet Format: IHTCGM_CGM
|
||||
Creation Date: March 25 2021
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTCGM_CGM_block(p_client_id,p_function_id, p_file_mnemonic,
|
||||
p_file_sheet_mnemonic, p_file_syspk)
|
||||
Function call ex: select staging2.fn_IHTCGM_CGM_block(1,2,'IHTCGM','IHTCGM_CGM',456)
|
||||
***************************************************************/
|
||||
|
||||
|
||||
SET search_path TO staging2;
|
||||
|
||||
/* to process multiple files - re-runnability*/
|
||||
|
||||
truncate table staging2.IHTCGM_CGM_H1_Int;
|
||||
truncate table staging2.IHTCGM_CGM_H1_block;
|
||||
truncate table staging2.IHTCGM_CGM_Weight_Tyre_Int;
|
||||
truncate table staging2.IHTCGM_CGM_Weight_Block;
|
||||
truncate table staging2.IHTCGM_CGM_Wheel_Block;
|
||||
truncate table staging2.IHTCGM_CGM_Tyre_Details_Block;
|
||||
truncate table staging2.IHTCGM_CGM_Lifting_Block;
|
||||
truncate table staging2.IHTCGM_CGM_Results_Block;
|
||||
truncate table staging2.IHTCGM_CGM_Footer_Block;
|
||||
truncate table staging2.stg_specific_table_IHTCGM_CGM;
|
||||
truncate table staging2.stg_process_table_IHTCGM_CGM;
|
||||
|
||||
|
||||
execute 'delete from fw_core.fw_jobctl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=null,
|
||||
row_previous_number=null,
|
||||
row_read_end=null,
|
||||
run_time=null
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* transfer data from generic to specific for IHTCGM */
|
||||
execute 'insert into staging2.stg_specific_table_IHTCGM_CGM
|
||||
select * from staging1.staging_generic_table a
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''
|
||||
and a.file_syspk='||p_file_syspk||'';
|
||||
|
||||
select count(*) into err_query from staging2.stg_specific_table_IHTCGM_CGM;
|
||||
|
||||
if err_query=0 then
|
||||
err_context := 'data not present';
|
||||
raise exception using
|
||||
message = 'No Data for IHT CGM',
|
||||
detail = 'No data in table stg_specific_table_IHTCGM_CGM',
|
||||
errcode = '42704',
|
||||
hint = 'check sheet mnemonic in generic table, if it is null update it';
|
||||
end if;
|
||||
|
||||
/* trimming data */
|
||||
update staging2.stg_specific_table_IHTCGM_CGM
|
||||
set column15='Objective' where lower(column15) like 'objective%';
|
||||
|
||||
update staging2.stg_specific_table_IHTCGM_CGM
|
||||
set column15='Acceptance criteria' where lower(column15) like 'acceptance criteria%';
|
||||
|
||||
update transactional.source_config set F1_source=F1_modified ;
|
||||
|
||||
|
||||
/* keyword match in config table*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=(select min(b.row_number)
|
||||
from staging2.stg_specific_table_IHTCGM_CGM b
|
||||
where upper(F1_modified)=upper(column3)
|
||||
and b.is_rownumber_fetched is null)
|
||||
where a.row_number_start is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* reverese update in process table for match*/
|
||||
execute 'update staging2.stg_specific_table_IHTCGM_CGM a
|
||||
set is_rownumber_fetched=1
|
||||
from transactional.source_config b
|
||||
where upper(F1_modified)=upper(column3)
|
||||
and b.row_number_start=a.row_number
|
||||
and is_rownumber_fetched is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'update transactional.source_config a set row_previous_number=row_number_start-1
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* update config files for row numbers start, end */
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end= (select b.row_number_start
|
||||
from transactional.source_config b
|
||||
where b.syspk=a.syspk+1 and file_mnemonic='''||p_file_mnemonic||''' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||''' )
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* config file last field update as null otherwise it picks up next format row number*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end = null ,run_time=current_timestamp
|
||||
where f1_modified =''Prepared by''
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* tagging block_row_numbers*/
|
||||
execute 'insert into staging2.stg_process_table_IHTCGM_CGM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTCGM_CGM a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Test Request no.''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTCGM_CGM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTCGM_CGM a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Weight Reaction''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTCGM_CGM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTCGM_CGM a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Lifting Angle & Load''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTCGM_CGM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTCGM_CGM a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Prepared by''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/*selecting tractor model*/
|
||||
select column6 into __model from staging2.stg_process_table_IHTCGM_CGM a
|
||||
where block_tag='IHTCGM_CGM_H1' and trim(column3)='Tractor Model';
|
||||
|
||||
/*block starts - IHTCGM_CGM_H1_BLOCK */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTCGM_CGM_H1_BLOCK',__file_mnemonic,__file_sheet_mnemonic,1);
|
||||
err_block:='IHTCGM_CGM_H1_BLOCK';
|
||||
|
||||
insert into staging2.IHTCGM_CGM_H1_INT (c1,c2)
|
||||
select a.column3,column6 from staging2.stg_process_table_IHTCGM_CGM a where block_tag='IHTCGM_CGM_H1';
|
||||
|
||||
insert into staging2.IHTCGM_CGM_H1_INT (c1,c2)
|
||||
select a.column9,column12 from staging2.stg_process_table_IHTCGM_CGM a where block_tag='IHTCGM_CGM_H1';
|
||||
|
||||
insert into staging2.IHTCGM_CGM_H1_INT (c1,c2)
|
||||
select 'Objective',column15
|
||||
from staging2.stg_process_table_IHTCGM_CGM a
|
||||
where block_tag='IHTCGM_CGM_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTCGM_CGM a
|
||||
where column15='Objective'
|
||||
and block_tag='IHTCGM_CGM_H1'
|
||||
);
|
||||
|
||||
insert into staging2.IHTCGM_CGM_H1_INT (c1,c2)
|
||||
select 'Acceptance criteria',column15
|
||||
from staging2.stg_process_table_IHTCGM_CGM a
|
||||
where block_tag='IHTCGM_CGM_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTCGM_CGM a
|
||||
where column15='Acceptance criteria'
|
||||
and block_tag='IHTCGM_CGM_H1'
|
||||
);
|
||||
|
||||
insert into staging2.IHTCGM_CGM_H1_INT (c1,c2)
|
||||
select split_part(column3,':',1),split_part(column3,':',2)
|
||||
from staging2.stg_process_table_IHTCGM_CGM
|
||||
where block_tag='IHTCGM_CGM_Lifting' and block_row_number=15;
|
||||
|
||||
insert into staging2.IHTCGM_CGM_H1_INT (c1,c2)
|
||||
select 'Test Purpose',column10
|
||||
from staging2.stg_process_table_IHTCGM_CGM a
|
||||
where block_tag='IHTCGM_CGM_H1' and column3='Test Purpose';
|
||||
|
||||
update staging2.IHTCGM_CGM_H1_Int set model=__model;
|
||||
execute 'update staging2.IHTCGM_CGM_H1_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
insert into staging2.IHTCGM_CGM_H1_Block
|
||||
(
|
||||
dummy_f,
|
||||
Test_Request_no,
|
||||
Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Tractor_Model,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date,
|
||||
No_of_Sample,
|
||||
Test_Start_Date,
|
||||
Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_Location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
Remarks,
|
||||
Test_Purpose
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{c2}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[c2::text]) AS val
|
||||
FROM staging2.IHTCGM_CGM_H1_INT
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,
|
||||
a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,
|
||||
a_18 text,a_19 text,a_20 text);
|
||||
|
||||
|
||||
delete from staging2.IHTCGM_CGM_H1_Block where dummy_f is null ;
|
||||
update staging2.IHTCGM_CGM_H1_Block set model=__model;
|
||||
execute 'update staging2.IHTCGM_CGM_H1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTCGM_CGM_H1_BLOCK');
|
||||
|
||||
|
||||
insert into staging2.IHTCGM_CGM_Weight_Tyre_Int
|
||||
(
|
||||
column3,column6,column10,column11,column13,column15,column17,column19,
|
||||
column20,block_row_number
|
||||
)
|
||||
select
|
||||
column3,column6,column10,column11,column13,column15,column17,column19,
|
||||
column20,block_row_number
|
||||
from staging2.stg_process_table_IHTCGM_CGM a
|
||||
where block_tag='IHTCGM_CGM_Weight_Tyre'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTCGM_CGM_Weight_Tyre_Int set model=__model;
|
||||
execute 'update staging2.IHTCGM_CGM_Weight_Tyre_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
update staging2.IHTCGM_CGM_Weight_Tyre_Int set trx_record = 0 where block_row_number=3;
|
||||
|
||||
/*block starts - IHTCGM_CGM_Weight_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTCGM_CGM_Weight_Block',__file_mnemonic,__file_sheet_mnemonic,2);
|
||||
err_block:='IHTCGM_CGM_Weight_Block';
|
||||
|
||||
insert into staging2.IHTCGM_CGM_Weight_Block
|
||||
(
|
||||
dummy_f,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg,
|
||||
Front_Reaction_kg,
|
||||
Rear_Reaction_kg,
|
||||
Left_Reaction_FL_RL_kg,
|
||||
Right_reaction_FR_RR_kg,
|
||||
Front_Left_Reaction_kg,
|
||||
Front_Right_Reaction_kg,
|
||||
Rear_Left_Reaction_kg,
|
||||
Rear_Right_Reaction_kg,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column6}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column6::text]) AS val
|
||||
FROM staging2.IHTCGM_CGM_Weight_Tyre_Int where trx_record=1
|
||||
ORDER BY generate_series(1,15),block_row_number,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text,
|
||||
a_10 text,a_11 text);
|
||||
|
||||
delete from staging2.IHTCGM_CGM_Weight_Block where dummy_f is null ;
|
||||
update staging2.IHTCGM_CGM_Weight_Block set model=__model;
|
||||
execute 'update staging2.IHTCGM_CGM_Weight_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTCGM_CGM_Weight_Block');
|
||||
|
||||
/*block starts - IHTCGM_CGM_Tyre_Details_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTCGM_CGM_Tyre_Details_Block',__file_mnemonic,__file_sheet_mnemonic,3);
|
||||
err_block:='IHTCGM_CGM_Tyre_Details_Block';
|
||||
insert into staging2.IHTCGM_CGM_Tyre_Details_Block
|
||||
(
|
||||
dummy_f,
|
||||
Tyre_Details,
|
||||
Tyre_Make,
|
||||
Tyre_size,
|
||||
Ply_Rating,
|
||||
Load_Carrying_Capacity,
|
||||
Pressure_kg_cm2,
|
||||
Dynamic_rolling_radius,
|
||||
Static_rolling_radius,
|
||||
Wheel_rim_Make_size
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column15,column19}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column15::text,column19::text]) AS val
|
||||
FROM staging2.IHTCGM_CGM_Weight_Tyre_Int where block_row_number between 3 and 11
|
||||
ORDER BY generate_series(1,15),block_row_number,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text);
|
||||
|
||||
delete from staging2.IHTCGM_CGM_Tyre_Details_Block where dummy_f is null ;
|
||||
update staging2.IHTCGM_CGM_Tyre_Details_Block set model=__model;
|
||||
execute 'update staging2.IHTCGM_CGM_Tyre_Details_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTCGM_CGM_Tyre_Details_Block');
|
||||
|
||||
|
||||
/*block starts - IHTCGM_CGM_Wheel_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTCGM_CGM_Wheel_Block',__file_mnemonic,__file_sheet_mnemonic,4);
|
||||
err_block:='IHTCGM_CGM_Wheel_Block';
|
||||
insert into staging2.IHTCGM_CGM_Wheel_Block(dummy_f) values ('dummy');
|
||||
|
||||
update staging2.IHTCGM_CGM_Wheel_Block
|
||||
set Wheel_Base=(select column13 from
|
||||
staging2.IHTCGM_CGM_Weight_Tyre_Int
|
||||
where block_row_number=1 and column10='Wheel Base in mm')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTCGM_CGM_Wheel_Block
|
||||
set Rear_Track_Width=(select column20 from
|
||||
staging2.IHTCGM_CGM_Weight_Tyre_Int
|
||||
where block_row_number=1 and column17='Rear Track Width in mm')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update staging2.IHTCGM_CGM_Wheel_Block set model=__model;
|
||||
execute 'update staging2.IHTCGM_CGM_Wheel_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTCGM_CGM_Wheel_Block');
|
||||
|
||||
/*block starts - IHTCGM_CGM_Lifting_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTCGM_CGM_Lifting_Block',__file_mnemonic,__file_sheet_mnemonic,5);
|
||||
err_block:='IHTCGM_CGM_Lifting_Block';
|
||||
|
||||
insert into staging2.IHTCGM_CGM_Lifting_Block
|
||||
(
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,block_row_number
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,block_row_number
|
||||
from staging2.stg_process_table_IHTCGM_CGM a
|
||||
where block_tag='IHTCGM_CGM_Lifting'
|
||||
order by block_row_number;
|
||||
|
||||
|
||||
|
||||
update staging2.IHTCGM_CGM_Lifting_Block set model=__model;
|
||||
execute 'update staging2.IHTCGM_CGM_Lifting_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
update staging2.IHTCGM_CGM_Lifting_Block set trx_record =0 where block_row_number not in (3,4,5,6,7,8,9);
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTCGM_CGM_Lifting_Block');
|
||||
|
||||
|
||||
/*block starts - IHTCGM_CGM_Results_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTCGM_CGM_Results_Block',__file_mnemonic,__file_sheet_mnemonic,6);
|
||||
err_block:='IHTCGM_CGM_Results_Block';
|
||||
insert into staging2.IHTCGM_CGM_Results_Block (dummy_f) values('dummy');
|
||||
|
||||
update staging2.IHTCGM_CGM_Results_Block
|
||||
set Determination_of_Horizontal_Distance_from_RAC_X=
|
||||
(select column10 from staging2.IHTCGM_CGM_Lifting_Block
|
||||
where block_row_number=12) where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTCGM_CGM_Results_Block
|
||||
set Determination_of_Lateral_CoOrdinate_in_Horizontal_Plane_Y=
|
||||
(select column10 from staging2.IHTCGM_CGM_Lifting_Block
|
||||
where block_row_number=13) where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTCGM_CGM_Results_Block
|
||||
set Determination_of_Vertical_CoOrdinate_Z=
|
||||
(select column10 from staging2.IHTCGM_CGM_Lifting_Block
|
||||
where block_row_number=14) where dummy_f='dummy';
|
||||
|
||||
|
||||
update staging2.IHTCGM_CGM_Results_Block set model=__model;
|
||||
execute 'update staging2.IHTCGM_CGM_Results_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTCGM_CGM_Results_Block');
|
||||
|
||||
|
||||
/*block starts - IHTCGM_CGM_Footer_block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTCGM_CGM_Footer_block',__file_mnemonic,__file_sheet_mnemonic,8);
|
||||
err_block='IHTCGM_CGM_Footer_block';
|
||||
insert into staging2.IHTCGM_CGM_Footer_block(dummy_f) values ('dummy');
|
||||
|
||||
update staging2.IHTCGM_CGM_Footer_block a
|
||||
set prepared_by=( select column7 from staging2.stg_process_table_IHTCGM_CGM b
|
||||
where b.block_tag='IHTCGM_CGM_Footer'
|
||||
and lower(column3)='prepared by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTCGM_CGM_Footer_block a
|
||||
set reviewed_by=( select column7 from staging2.stg_process_table_IHTCGM_CGM b
|
||||
where b.block_tag='IHTCGM_CGM_Footer'
|
||||
and lower(column3)='reviewed by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTCGM_CGM_Footer_block a
|
||||
set approved_by=( select column7 from staging2.stg_process_table_IHTCGM_CGM b
|
||||
where b.block_tag='IHTCGM_CGM_Footer'
|
||||
and lower(column3)='approved by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTCGM_CGM_Footer_block a
|
||||
set comments=( select column3 from staging2.stg_process_table_IHTCGM_CGM b
|
||||
where b.block_tag='IHTCGM_CGM_Footer'
|
||||
and block_row_number=5 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTCGM_CGM_Footer_block a
|
||||
set rev1=( select column3 from staging2.stg_process_table_IHTCGM_CGM b
|
||||
where b.block_tag='IHTCGM_CGM_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
update staging2.IHTCGM_CGM_Footer_block a
|
||||
set rev2=( select column9 from staging2.stg_process_table_IHTCGM_CGM b
|
||||
where b.block_tag='IHTCGM_CGM_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTCGM_CGM_Footer_block a
|
||||
set rev3=( select column18 from staging2.stg_process_table_IHTCGM_CGM b
|
||||
where b.block_tag='IHTCGM_CGM_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTCGM_CGM_Footer_block a
|
||||
set replaces=( select column19 from staging2.stg_process_table_IHTCGM_CGM b
|
||||
where b.block_tag='IHTCGM_CGM_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTCGM_CGM_Footer_block a
|
||||
set revision_no=( select column19 from staging2.stg_process_table_IHTCGM_CGM b
|
||||
where b.block_tag='IHTCGM_CGM_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTCGM_CGM_Footer_block a
|
||||
set prepared_date=( select column16 from staging2.stg_process_table_IHTCGM_CGM b
|
||||
where b.block_tag='IHTCGM_CGM_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTCGM_CGM_Footer_block a
|
||||
set reviewed_date=( select column16 from staging2.stg_process_table_IHTCGM_CGM b
|
||||
where b.block_tag='IHTCGM_CGM_Footer'
|
||||
and block_row_number=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTCGM_CGM_Footer_block a
|
||||
set approved_date=( select column16 from staging2.stg_process_table_IHTCGM_CGM b
|
||||
where b.block_tag='IHTCGM_CGM_Footer'
|
||||
and block_row_number=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTCGM_CGM_Footer_block set model=__model;
|
||||
execute 'update staging2.IHTCGM_CGM_Footer_block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTCGM_CGM_Footer_block');
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'stg2', 'fn_IHTCGM_CGM_block', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
434
onetime/dataloadfunctions/IHT/IHT_EMT_ODS.sql
Executable file
434
onetime/dataloadfunctions/IHT/IHT_EMT_ODS.sql
Executable file
@@ -0,0 +1,434 @@
|
||||
drop function if exists staging2.fn_IHTEMT_EMT_TRX;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTEMT_EMT_TRX(p_client_id int,p_function_id int, p_file_mnemonic text,
|
||||
p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __test_instance_id int;
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare _error int;
|
||||
declare __test_master_id int;
|
||||
declare __test_instance_tractor_id int;
|
||||
begin
|
||||
__file_syspk := p_file_syspk;
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTEMT_EMT_TRX
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHTEMT
|
||||
Sheet Format: IHTEMT_EMT
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTEMT_EMT_TRX()
|
||||
***************************************************************/
|
||||
insert into transactional.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
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,
|
||||
objective_of_test,
|
||||
acceptance_criteria,
|
||||
remarks,
|
||||
test_purpose
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
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,
|
||||
Remarks,
|
||||
Test_Purpose
|
||||
from staging2.IHTEMT_EMT_H1_block where trx_record =1;
|
||||
|
||||
update transactional.test_instance a
|
||||
set
|
||||
report_prepared_date=to_date(b.prepared_date,'DD-MM-YYYY'),
|
||||
report_reviewed_date=to_date(b.reviewed_date,'DD-MM-YYYY'),
|
||||
report_approved_date=to_date(b.approved_date,'DD-MM-YYYY'),
|
||||
report_prepared_by=b.prepared_by,
|
||||
report_reviewed_by=b.reviewed_by,
|
||||
report_approved_by=b.approved_by,
|
||||
report_template_replaces=b.replaces,
|
||||
report_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from staging2.IHTEMT_EMT_footer_block b
|
||||
where a.file_sheet_mnemonic ='IHTEMT_EMT' and trx_record =1;
|
||||
|
||||
insert into transactional.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tyre_type,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
tyre_ply_rating,
|
||||
tyre_load_carrying_capacity,
|
||||
tyre_pressure_kg_per_cm2,
|
||||
tyre_static_rolling_radius_mm,
|
||||
tyre_dynamic_rolling_radius_mm,
|
||||
tyre_wheel_rim_make_and_size
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
tyre_details,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
ply_rating::numeric,
|
||||
load_carrying_capacity,
|
||||
Pressure_kg_cm2::numeric ,
|
||||
Dynamic_rolling_radius::numeric ,
|
||||
Static_rolling_radius::numeric ,
|
||||
wheel_rim_make_size
|
||||
from staging2.IHTEMT_EMT_tyre_details_block where trx_record =1;
|
||||
|
||||
insert into transactional.test_instance_tractor_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
wheel_base_mm,
|
||||
turning_circle_diameter_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
wheel_base::numeric ,
|
||||
tcd::numeric
|
||||
from staging2.IHTEMT_EMT_wheel_block where trx_record =1;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set mahindra_model_yn = (
|
||||
case when tractor_make like 'Mahindra%' then 'Y' else 'N' end
|
||||
) where file_syspk =__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info a
|
||||
set test_tractor_yn ='Y' where syspk in
|
||||
(select min(syspk) from transactional.test_instance_tractor_info b
|
||||
where b.file_syspk =a.file_syspk)
|
||||
and a.file_syspk =__file_syspk;
|
||||
|
||||
|
||||
/*block */
|
||||
|
||||
insert into transactional.test_instance_weight_reaction
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
total_weight_kg,
|
||||
front_reaction_kg,
|
||||
rear_reaction_kg,
|
||||
left_reaction_fl_rl_kg,
|
||||
right_reaction_fr_rr_kg,
|
||||
front_left_reaction_kg,
|
||||
front_right_reactionkg,
|
||||
rear_left_reaction_kg,
|
||||
rear_right_reactionkg,
|
||||
distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg::numeric,
|
||||
Front_Reaction_kg::numeric ,
|
||||
Rear_Reaction_kg::numeric ,
|
||||
Left_Reaction_FL_RL_kg::numeric ,
|
||||
Right_reaction_FR_RR_kg::numeric ,
|
||||
Front_Left_Reaction_kg::numeric ,
|
||||
Front_Right_Reaction_kg::numeric ,
|
||||
Rear_Left_Reaction_kg::numeric ,
|
||||
Rear_Right_Reaction_kg::numeric ,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1::numeric
|
||||
from staging2.IHTEMT_EMT_weight_block where trx_record =1;
|
||||
|
||||
|
||||
insert into transactional.IHT_steering_effort
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_speed_kmph,
|
||||
max_angle_lh,
|
||||
max_angle_rh,
|
||||
max_effort_lh,
|
||||
max_effort_rh
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column8::numeric
|
||||
from staging2.IHTEMT_emt_steering_block where trx_record=1;
|
||||
|
||||
insert into transactional.IHT_pedal_effort
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
parameters,
|
||||
efforts_kg,
|
||||
travel_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric ,
|
||||
column4::numeric
|
||||
from staging2.IHTEMT_emt_pedal_block where trx_record=1;
|
||||
|
||||
insert into transactional.IHT_gear_effort
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
parameters,
|
||||
efforts_kg
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column5,
|
||||
column8::numeric
|
||||
from staging2.IHTEMT_emt_pedal_block where trx_record=1;
|
||||
|
||||
insert into transactional.IHT_brake_pedal_effort
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
srl_no,
|
||||
pedal_effort_kg,
|
||||
pedal_travel_lh_mm,
|
||||
pedal_travel_rh_mm,
|
||||
pedal_travel_latched_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2::numeric,
|
||||
column3::numeric,
|
||||
column4::numeric ,
|
||||
column5::numeric,
|
||||
column6::numeric
|
||||
from staging2.IHTEMT_emt_brake_pedal_block where trx_record=1;
|
||||
|
||||
insert into transactional.IHT_clutch_pedal_effort
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
srl_no,
|
||||
pedal_effort_kg,
|
||||
pedal_travel_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9::numeric
|
||||
from staging2.IHTEMT_emt_brake_pedal_block where trx_record=1;
|
||||
|
||||
|
||||
select syspk into __test_instance_id from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_model into __model from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_make into __make from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select syspk from transactional.test_master into __test_master_id where test_type ='In House';
|
||||
select syspk into __test_instance_tractor_id from transactional.test_instance_tractor_info where file_syspk =__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance
|
||||
set test_master_id =__test_master_id,
|
||||
test_tractor_id =__test_instance_tractor_id
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_weight_reaction
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.IHT_brake_pedal_effort
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.IHT_pedal_effort
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.IHT_steering_effort
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.IHT_gear_effort
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.IHT_clutch_pedal_effort
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'trx', 'fn_IHTEMT_EMT_TRX', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
91
onetime/dataloadfunctions/IHT/IHT_EMT_STD_ODS.sql
Executable file
91
onetime/dataloadfunctions/IHT/IHT_EMT_STD_ODS.sql
Executable file
@@ -0,0 +1,91 @@
|
||||
|
||||
drop function if exists staging2.fn_IHTEMT_STD_TRX;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTEMT_STD_TRX(p_client_id int,p_function_id int, p_file_mnemonic text,
|
||||
p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __test_instance_id int;
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare _error int;
|
||||
declare __test_master_id int;
|
||||
declare __test_instance_tractor_id int;
|
||||
begin
|
||||
__file_syspk := p_file_syspk;
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTEMT_STD_TRX
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHTEMT
|
||||
Sheet Format: IHTEMT_STD
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTEMT_STD_TRX()
|
||||
***************************************************************/
|
||||
|
||||
insert into transactional.iht_steering_effort_raw_data
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
time_sec,
|
||||
steering_anglel,
|
||||
effort_kg
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
time_s::numeric,
|
||||
steering_angle ::numeric,
|
||||
effort ::numeric
|
||||
from staging2.IHTEMT_STD_RAW_Data_Block where trx_record=1;
|
||||
|
||||
|
||||
select syspk into __test_instance_id from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_model into __model from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_make into __make from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select syspk from transactional.test_master into __test_master_id where test_type ='In House';
|
||||
select syspk into __test_instance_tractor_id from transactional.test_instance_tractor_info where file_syspk =__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance
|
||||
set test_master_id =__test_master_id,
|
||||
test_tractor_id =__test_instance_tractor_id
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'trx', 'fn_IHTEMT_STD_TRX', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
149
onetime/dataloadfunctions/IHT/IHT_EMT_STD_STG2.sql
Executable file
149
onetime/dataloadfunctions/IHT/IHT_EMT_STD_STG2.sql
Executable file
@@ -0,0 +1,149 @@
|
||||
drop function if exists staging2.fn_IHTEMT_STD_block;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTEMT_STD_block(p_client_id int,p_function_id int, p_file_mnemonic text,p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare err_query int;
|
||||
declare err_block text;
|
||||
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTEMT_STD_block
|
||||
Function Desc: This function populates data into staging 2 block
|
||||
File Format: IHTEMT
|
||||
Sheet Format: IHTEMT_STD
|
||||
Creation Date: March 25 2021
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTEMT_STD_block(p_client_id,p_function_id, p_file_mnemonic,
|
||||
p_file_sheet_mnemonic, p_file_syspk)
|
||||
Function call ex: select staging2.fn_IHTEMT_STD_block(1,2,'IHTEMT','IHTEMT_STD',456)
|
||||
***************************************************************/
|
||||
|
||||
|
||||
SET search_path TO staging2;
|
||||
|
||||
/* to process multiple files - re-runnability*/
|
||||
|
||||
truncate table staging2.IHTEMT_STD_RAW_Data_Block;
|
||||
truncate table staging2.stg_specific_table_IHTEMT_STD;
|
||||
truncate table staging2.stg_process_table_IHTEMT_STD;
|
||||
|
||||
|
||||
execute 'delete from fw_core.fw_jobctl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=null,
|
||||
row_previous_number=null,
|
||||
row_read_end=null,
|
||||
run_time=null
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* transfer data from generic to specific for IHTEMT */
|
||||
execute 'insert into staging2.stg_specific_table_IHTEMT_STD
|
||||
select * from staging1.staging_generic_table a
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''
|
||||
and a.file_syspk='||p_file_syspk||'';
|
||||
|
||||
select count(*) into err_query from staging2.stg_specific_table_IHTEMT_STD;
|
||||
|
||||
if err_query=0 then
|
||||
err_context := 'data not present';
|
||||
raise exception using
|
||||
message = 'No Data for IHTEMT STD',
|
||||
detail = 'No data in table stg_specific_table_IHTEMT_STD',
|
||||
errcode = '42704',
|
||||
hint = 'check sheet mnemonic in generic table, if it is null update it';
|
||||
end if;
|
||||
|
||||
update transactional.source_config set F1_source=F1_modified ;
|
||||
|
||||
|
||||
/* keyword match in config table*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=(select min(b.row_number)
|
||||
from staging2.stg_specific_table_IHTEMT_STD b
|
||||
where upper(F1_modified)=upper(column1)
|
||||
and b.is_rownumber_fetched is null)
|
||||
where a.row_number_start is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* reverese update in process table for match*/
|
||||
execute 'update staging2.stg_specific_table_IHTEMT_STD a
|
||||
set is_rownumber_fetched=1
|
||||
from transactional.source_config b
|
||||
where upper(F1_modified)=upper(column1)
|
||||
and b.row_number_start=a.row_number
|
||||
and is_rownumber_fetched is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'update transactional.source_config a set row_previous_number=row_number_start-1
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* update config files for row numbers start, end */
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end= (select b.row_number_start
|
||||
from transactional.source_config b
|
||||
where b.syspk=a.syspk+1 and file_mnemonic='''||p_file_mnemonic||''' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||''' )
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* config file last field update as null otherwise it picks up next format row number*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end = null ,run_time=current_timestamp
|
||||
where f1_modified =''Steering effort RAW data''
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* tagging block_row_numbers*/
|
||||
execute 'insert into staging2.stg_process_table_IHTEMT_STD
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTEMT_STD a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Steering effort RAW data''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
/*block starts - IHTEMT_STD_H1_BLOCK */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTEMT_STD_RAW_Data_Block',__file_mnemonic,__file_sheet_mnemonic,1);
|
||||
|
||||
err_block:='IHTEMT_STD_RAW_Data_Block';
|
||||
insert into staging2.IHTEMT_STD_RAW_Data_Block (Time_s,Steering_Angle,Effort,block_row_number)
|
||||
select a.column1,column2,column3,block_row_number from staging2.stg_process_table_IHTEMT_STD a
|
||||
where block_tag='IHTEMT_STD_RAW_Data';
|
||||
|
||||
|
||||
execute 'update staging2.IHTEMT_STD_RAW_Data_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
update staging2.IHTEMT_STD_RAW_Data_Block set trx_record =0 where block_row_number in (1,2,3);
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTEMT_STD_RAW_Data_Block');
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'stg2', 'fn_IHTEMT_STD_block', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
615
onetime/dataloadfunctions/IHT/IHT_EMT_STG2.sql
Executable file
615
onetime/dataloadfunctions/IHT/IHT_EMT_STG2.sql
Executable file
@@ -0,0 +1,615 @@
|
||||
drop function if exists staging2.fn_IHTEMT_EMT_block;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTEMT_EMT_block(p_client_id int,p_function_id int, p_file_mnemonic text,p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare err_query int;
|
||||
declare err_block text;
|
||||
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTEMT_EMT_block
|
||||
Function Desc: This function populates data into staging 2 block
|
||||
File Format: IHTEMT
|
||||
Sheet Format: IHTEMT_EMT
|
||||
Creation Date: March 25 2021
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTEMT_EMT_block(p_client_id,p_function_id, p_file_mnemonic,
|
||||
p_file_sheet_mnemonic, p_file_syspk)
|
||||
Function call ex: select staging2.fn_IHTEMT_EMT_block(1,2,'IHTEMT','IHTEMT_EMT',456)
|
||||
***************************************************************/
|
||||
|
||||
|
||||
SET search_path TO staging2;
|
||||
|
||||
/* to process multiple files - re-runnability*/
|
||||
|
||||
truncate table staging2.IHTEMT_EMT_H1_INT;
|
||||
truncate table staging2.IHTEMT_EMT_H1_block;
|
||||
truncate table staging2.IHTEMT_EMT_Weight_Tyre_Int;
|
||||
truncate table staging2.IHTEMT_EMT_Weight_Block;
|
||||
truncate table staging2.IHTEMT_EMT_Wheel_Block;
|
||||
truncate table staging2.IHTEMT_EMT_Tyre_Details_Block;
|
||||
truncate table staging2.IHTEMT_EMT_Steering_Block;
|
||||
truncate table staging2.IHTEMT_EMT_Pedal_Block;
|
||||
truncate table staging2.IHTEMT_EMT_Brake_Pedal_Block;
|
||||
truncate table staging2.IHTEMT_EMT_Footer_Block;
|
||||
truncate table staging2.stg_specific_table_IHTEMT_EMT;
|
||||
truncate table staging2.stg_process_table_IHTEMT_EMT;
|
||||
|
||||
|
||||
execute 'delete from fw_core.fw_jobctl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=null,
|
||||
row_previous_number=null,
|
||||
row_read_end=null,
|
||||
run_time=null
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* transfer data from generic to specific for IHTEMT */
|
||||
execute 'insert into staging2.stg_specific_table_IHTEMT_EMT
|
||||
select * from staging1.staging_generic_table a
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''
|
||||
and a.file_syspk='||p_file_syspk||'';
|
||||
|
||||
select count(*) into err_query from staging2.stg_specific_table_IHTEMT_EMT;
|
||||
|
||||
if err_query=0 then
|
||||
err_context := 'data not present';
|
||||
raise exception using
|
||||
message = 'No Data for IHTEMT EMT',
|
||||
detail = 'No data in table stg_specific_table_IHTEMT_EMT',
|
||||
errcode = '42704',
|
||||
hint = 'check sheet mnemonic in generic table, if it is null update it';
|
||||
end if;
|
||||
|
||||
/* trimming data */
|
||||
update staging2.stg_specific_table_IHTEMT_EMT
|
||||
set column14='Objective' where lower(column14) like 'objective%';
|
||||
|
||||
update staging2.stg_specific_table_IHTEMT_EMT
|
||||
set column14='Acceptance criteria' where lower(column14) like 'acceptance criteria%';
|
||||
|
||||
|
||||
update transactional.source_config set F1_source=F1_modified ;
|
||||
|
||||
/* keyword match in config table*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=(select min(b.row_number)
|
||||
from staging2.stg_specific_table_IHTEMT_EMT b
|
||||
where upper(F1_modified)=upper(column2)
|
||||
and b.is_rownumber_fetched is null)
|
||||
where a.row_number_start is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* reverese update in process table for match*/
|
||||
execute 'update staging2.stg_specific_table_IHTEMT_EMT a
|
||||
set is_rownumber_fetched=1
|
||||
from transactional.source_config b
|
||||
where upper(F1_modified)=upper(column2)
|
||||
and b.row_number_start=a.row_number
|
||||
and is_rownumber_fetched is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'update transactional.source_config a set row_previous_number=row_number_start-1
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* update config files for row numbers start, end */
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end= (select b.row_number_start
|
||||
from transactional.source_config b
|
||||
where b.syspk=a.syspk+1 and file_mnemonic='''||p_file_mnemonic||''' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||''' )
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* config file last field update as null otherwise it picks up next format row number*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end = null ,run_time=current_timestamp
|
||||
where f1_modified =''Prepared by''
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* tagging block_row_numbers*/
|
||||
execute 'insert into staging2.stg_process_table_IHTEMT_EMT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTEMT_EMT a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Test Request no.''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTEMT_EMT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTEMT_EMT a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Weight Reaction''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTEMT_EMT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTEMT_EMT a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Steering effort''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTEMT_EMT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTEMT_EMT a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Pedal Effort''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTEMT_EMT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTEMT_EMT a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Brake Pedal Effort''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTEMT_EMT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTEMT_EMT a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Prepared by''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/*selecting tractor model and make*/
|
||||
select column5 into __make from staging2.stg_process_table_IHTEMT_EMT a
|
||||
where block_tag='IHTEMT_EMT_H1' and trim(column2)='Tractor Model';
|
||||
|
||||
|
||||
select column5 into __model from staging2.stg_process_table_IHTEMT_EMT a
|
||||
where block_tag='IHTEMT_EMT_H1' and trim(column2)='Tractor Model';
|
||||
|
||||
/*block starts - IHTEMT_EMT_H1_BLOCK */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTEMT_EMT_H1_BLOCK',__file_mnemonic,__file_sheet_mnemonic,1);
|
||||
err_block:='IHTEMT_EMT_H1_BLOCK';
|
||||
insert into staging2.IHTEMT_EMT_H1_INT (c1,c2)
|
||||
select a.column2,column5 from staging2.stg_process_table_IHTEMT_EMT a where block_tag='IHTEMT_EMT_H1';
|
||||
|
||||
insert into staging2.IHTEMT_EMT_H1_INT (c1,c2)
|
||||
select a.column8,column11 from staging2.stg_process_table_IHTEMT_EMT a where block_tag='IHTEMT_EMT_H1';
|
||||
|
||||
insert into staging2.IHTEMT_EMT_H1_INT (c1,c2)
|
||||
select 'Objective',column14
|
||||
from staging2.stg_process_table_IHTEMT_EMT a
|
||||
where block_tag='IHTEMT_EMT_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTEMT_EMT a
|
||||
where column14='Objective'
|
||||
and block_tag='IHTEMT_EMT_H1'
|
||||
);
|
||||
|
||||
insert into staging2.IHTEMT_EMT_H1_INT (c1,c2)
|
||||
select 'Acceptance criteria',column14
|
||||
from staging2.stg_process_table_IHTEMT_EMT a
|
||||
where block_tag='IHTEMT_EMT_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTEMT_EMT a
|
||||
where column14='Acceptance criteria'
|
||||
and block_tag='IHTEMT_EMT_H1'
|
||||
);
|
||||
|
||||
insert into staging2.IHTEMT_EMT_H1_INT (c1,c2)
|
||||
select split_part(column2,':',1),split_part(column2,':',2)
|
||||
from staging2.stg_process_table_IHTEMT_EMT
|
||||
where block_tag='IHTEMT_EMT_Footer' and block_row_number=1;
|
||||
|
||||
insert into staging2.IHTEMT_EMT_H1_INT (c1,c2)
|
||||
select 'Test Purpose',column9
|
||||
from staging2.stg_process_table_IHTEMT_EMT
|
||||
where block_tag='IHTEMT_EMT_Weight_Tyre' and column2='Test Purpose';
|
||||
|
||||
|
||||
update staging2.IHTEMT_EMT_H1_Int set model=__model;
|
||||
execute 'update staging2.IHTEMT_EMT_H1_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
insert into staging2.IHTEMT_EMT_H1_Block
|
||||
(
|
||||
dummy_f,
|
||||
Test_Request_no,
|
||||
Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Tractor_Model,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date,
|
||||
No_of_Sample,
|
||||
Test_Start_Date,
|
||||
Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_Location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
Remarks,
|
||||
Test_Purpose
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{c2}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[c2::text]) AS val
|
||||
FROM staging2.IHTEMT_EMT_H1_INT
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,
|
||||
a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,
|
||||
a_18 text,a_19 text,a_20 text);
|
||||
|
||||
|
||||
delete from staging2.IHTEMT_EMT_H1_Block where dummy_f is null ;
|
||||
update staging2.IHTEMT_EMT_H1_Block set model=__model;
|
||||
execute 'update staging2.IHTEMT_EMT_H1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTEMT_EMT_H1_BLOCK');
|
||||
|
||||
|
||||
insert into staging2.IHTEMT_EMT_Weight_Tyre_Int
|
||||
(
|
||||
column2,column5,column9,column10,column12,column14,column16,column18,
|
||||
column19,block_row_number
|
||||
)
|
||||
select
|
||||
column2,column5,column9,column10,column12,column14,column16,column18,
|
||||
column19,block_row_number
|
||||
from staging2.stg_process_table_IHTEMT_EMT a
|
||||
where block_tag='IHTEMT_EMT_Weight_Tyre'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTEMT_EMT_Weight_Tyre_Int set model=__model;
|
||||
execute 'update staging2.IHTEMT_EMT_Weight_Tyre_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
/*block starts - IHTEMT_EMT_Weight_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTEMT_EMT_Weight_Block',__file_mnemonic,__file_sheet_mnemonic,2);
|
||||
err_block:='IHTEMT_EMT_Weight_Block';
|
||||
|
||||
insert into staging2.IHTEMT_EMT_Weight_Block
|
||||
(
|
||||
dummy_f,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg,
|
||||
Front_Reaction_kg,
|
||||
Rear_Reaction_kg,
|
||||
Left_Reaction_FL_RL_kg,
|
||||
Right_reaction_FR_RR_kg,
|
||||
Front_Left_Reaction_kg,
|
||||
Front_Right_Reaction_kg,
|
||||
Rear_Left_Reaction_kg,
|
||||
Rear_Right_Reaction_kg,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column5}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column5::text]) AS val
|
||||
FROM staging2.IHTEMT_EMT_Weight_Tyre_Int
|
||||
ORDER BY generate_series(1,15),block_row_number,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text,
|
||||
a_10 text,a_11 text);
|
||||
|
||||
|
||||
delete from staging2.IHTEMT_EMT_Weight_Block where dummy_f is null ;
|
||||
update staging2.IHTEMT_EMT_Weight_Block set model=__model;
|
||||
execute 'update staging2.IHTEMT_EMT_Weight_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTEMT_EMT_Weight_Block');
|
||||
|
||||
/*block starts - IHTEMT_EMT_Tyre_Details_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTEMT_EMT_Tyre_Details_Block',__file_mnemonic,__file_sheet_mnemonic,3);
|
||||
err_block:='IHTEMT_EMT_Tyre_Details_Block';
|
||||
|
||||
insert into staging2.IHTEMT_EMT_Tyre_Details_Block
|
||||
(
|
||||
dummy_f,
|
||||
Tyre_Details,
|
||||
Tyre_Make,
|
||||
Tyre_size,
|
||||
Ply_Rating,
|
||||
Load_Carrying_Capacity,
|
||||
Pressure_kg_cm2,
|
||||
Dynamic_rolling_radius,
|
||||
Static_rolling_radius,
|
||||
Wheel_rim_Make_size
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column14,column18}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column14::text,column18::text]) AS val
|
||||
FROM staging2.IHTEMT_EMT_Weight_Tyre_Int where block_row_number between 3 and 11
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text);
|
||||
|
||||
delete from staging2.IHTEMT_EMT_Tyre_Details_Block where dummy_f is null ;
|
||||
update staging2.IHTEMT_EMT_Tyre_Details_Block set model=__model;
|
||||
execute 'update staging2.IHTEMT_EMT_Tyre_Details_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTEMT_EMT_Tyre_Details_Block');
|
||||
|
||||
|
||||
/*block starts - IHTEMT_EMT_Wheel_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTEMT_EMT_Wheel_Block',__file_mnemonic,__file_sheet_mnemonic,4);
|
||||
err_block:='IHTEMT_EMT_Wheel_Block';
|
||||
insert into staging2.IHTEMT_EMT_Wheel_Block(dummy_f) values ('dummy');
|
||||
|
||||
update staging2.IHTEMT_EMT_Wheel_Block
|
||||
set Wheel_Base=(select column12 from
|
||||
staging2.IHTEMT_EMT_Weight_Tyre_Int
|
||||
where block_row_number=1 and column9='Wheel Base in mm')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTEMT_EMT_Wheel_Block
|
||||
set TCD=(select replace(column19,'mm','') from
|
||||
staging2.IHTEMT_EMT_Weight_Tyre_Int
|
||||
where block_row_number=1 and column16='TCD in mm')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update staging2.IHTEMT_EMT_Wheel_Block set model=__model;
|
||||
execute 'update staging2.IHTEMT_EMT_Wheel_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTEMT_EMT_Wheel_Block');
|
||||
|
||||
/*block starts - IHTEMT_EMT_Steering_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTEMT_EMT_Steering_Block',__file_mnemonic,__file_sheet_mnemonic,5);
|
||||
err_block:='IHTEMT_EMT_Steering_Block';
|
||||
|
||||
insert into staging2.IHTEMT_EMT_Steering_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,
|
||||
column8,block_row_number
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,
|
||||
column8,block_row_number
|
||||
from staging2.stg_process_table_IHTEMT_EMT a
|
||||
where block_tag='IHTEMT_EMT_Steering'
|
||||
order by block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTEMT_EMT_Steering_Block set model=__model;
|
||||
execute 'update staging2.IHTEMT_EMT_Steering_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
update staging2.IHTEMT_EMT_Steering_Block set trx_record =0 where block_row_number in (1,2,3);
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTEMT_EMT_Steering_Block');
|
||||
|
||||
|
||||
/*block starts - IHTEMT_EMT_Pedal_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTEMT_EMT_Pedal_Block',__file_mnemonic,__file_sheet_mnemonic,6);
|
||||
err_block:='IHTEMT_EMT_Pedal_Block';
|
||||
insert into staging2.IHTEMT_EMT_Pedal_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,
|
||||
column8,block_row_number
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,
|
||||
column8,block_row_number
|
||||
from staging2.stg_process_table_IHTEMT_EMT a
|
||||
where block_tag='IHTEMT_EMT_Pedal'
|
||||
order by block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTEMT_EMT_Pedal_Block set model=__model;
|
||||
execute 'update staging2.IHTEMT_EMT_Pedal_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
update staging2.IHTEMT_EMT_Pedal_Block set trx_record =0 where block_row_number in (1,2);
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTEMT_EMT_Pedal_Block');
|
||||
|
||||
/*block starts - IHTEMT_EMT_Brake_Pedal_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTEMT_EMT_Brake_Pedal_Block',__file_mnemonic,__file_sheet_mnemonic,7);
|
||||
err_block:='IHTEMT_EMT_Brake_Pedal_Block';
|
||||
insert into staging2.IHTEMT_EMT_Brake_Pedal_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,block_row_number
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,block_row_number
|
||||
from staging2.stg_process_table_IHTEMT_EMT a
|
||||
where block_tag='IHTEMT_EMT_Brake_Pedal'
|
||||
order by block_row_number;
|
||||
|
||||
|
||||
|
||||
update staging2.IHTEMT_EMT_Brake_Pedal_Block set model=__model;
|
||||
execute 'update staging2.IHTEMT_EMT_Brake_Pedal_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
update staging2.IHTEMT_EMT_Brake_Pedal_Block set trx_record =0 where block_row_number in (1,2,3,14);
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTEMT_EMT_Brake_Pedal_Block');
|
||||
|
||||
/*block starts - IHTEMT_EMT_Footer_block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTEMT_EMT_Footer_block',__file_mnemonic,__file_sheet_mnemonic,8);
|
||||
err_block:='IHTEMT_EMT_Footer_block';
|
||||
insert into staging2.IHTEMT_EMT_Footer_block(dummy_f) values ('dummy');
|
||||
|
||||
update staging2.IHTEMT_EMT_Footer_block a
|
||||
set prepared_by=( select column6 from staging2.stg_process_table_IHTEMT_EMT b
|
||||
where b.block_tag='IHTEMT_EMT_Footer'
|
||||
and lower(column2)='prepared by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTEMT_EMT_Footer_block a
|
||||
set reviewed_by=( select column6 from staging2.stg_process_table_IHTEMT_EMT b
|
||||
where b.block_tag='IHTEMT_EMT_Footer'
|
||||
and lower(column2)='reviewed by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTEMT_EMT_Footer_block a
|
||||
set approved_by=( select column6 from staging2.stg_process_table_IHTEMT_EMT b
|
||||
where b.block_tag='IHTEMT_EMT_Footer'
|
||||
and lower(column2)='approved by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTEMT_EMT_Footer_block a
|
||||
set comments=( select column2 from staging2.stg_process_table_IHTEMT_EMT b
|
||||
where b.block_tag='IHTEMT_EMT_Footer'
|
||||
and block_row_number=5 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTEMT_EMT_Footer_block a
|
||||
set rev1=( select column2 from staging2.stg_process_table_IHTEMT_EMT b
|
||||
where b.block_tag='IHTEMT_EMT_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
update staging2.IHTEMT_EMT_Footer_block a
|
||||
set rev2=( select column8 from staging2.stg_process_table_IHTEMT_EMT b
|
||||
where b.block_tag='IHTEMT_EMT_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTEMT_EMT_Footer_block a
|
||||
set rev3=( select column17 from staging2.stg_process_table_IHTEMT_EMT b
|
||||
where b.block_tag='IHTEMT_EMT_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTEMT_EMT_Footer_block a
|
||||
set replaces=( select column18 from staging2.stg_process_table_IHTEMT_EMT b
|
||||
where b.block_tag='IHTEMT_EMT_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTEMT_EMT_Footer_block a
|
||||
set revision_no=( select column18 from staging2.stg_process_table_IHTEMT_EMT b
|
||||
where b.block_tag='IHTEMT_EMT_Footer'
|
||||
and block_row_number=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTEMT_EMT_Footer_block a
|
||||
set prepared_date=( select column15 from staging2.stg_process_table_IHTEMT_EMT b
|
||||
where b.block_tag='IHTEMT_EMT_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTEMT_EMT_Footer_block a
|
||||
set reviewed_date=( select column15 from staging2.stg_process_table_IHTEMT_EMT b
|
||||
where b.block_tag='IHTEMT_EMT_Footer'
|
||||
and block_row_number=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTEMT_EMT_Footer_block a
|
||||
set approved_date=( select column15 from staging2.stg_process_table_IHTEMT_EMT b
|
||||
where b.block_tag='IHTEMT_EMT_Footer'
|
||||
and block_row_number=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTEMT_EMT_Footer_block set model=__model;
|
||||
execute 'update staging2.IHTEMT_EMT_Footer_block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTEMT_EMT_Footer_block');
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'stg2', 'fn_IHTEMT_EMT_block', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
433
onetime/dataloadfunctions/IHT/IHT_HAM_ODS.sql
Executable file
433
onetime/dataloadfunctions/IHT/IHT_HAM_ODS.sql
Executable file
@@ -0,0 +1,433 @@
|
||||
drop function if exists staging2.fn_IHTHAM_HAM_TRX;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTHAM_HAM_TRX(p_client_id int,p_function_id int, p_file_mnemonic text,
|
||||
p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __test_instance_id int;
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare _error int;
|
||||
declare __test_master_id int;
|
||||
declare __test_instance_tractor_id int;
|
||||
begin
|
||||
__file_syspk := p_file_syspk;
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTHAM_HAM_TRX
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHTHAM
|
||||
Sheet Format: IHTHAM_HAM
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTHAM_HAM_TRX()
|
||||
***************************************************************/
|
||||
insert into transactional.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
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,
|
||||
objective_of_test,
|
||||
acceptance_criteria,
|
||||
test_condition,
|
||||
remarks
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
Test_Request_no,
|
||||
Sample_Receipt_Date::date,
|
||||
Test_report_No,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date::date,
|
||||
No_of_Sample,
|
||||
Test_Start_Date::date,
|
||||
Test_End_Date::date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Acceptance_criteria,
|
||||
Objective,
|
||||
condition,
|
||||
Remarks
|
||||
from
|
||||
staging2.IHTHAM_HAM_H1_block where trx_record=1;
|
||||
|
||||
update transactional.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_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from staging2.IHTHAM_HAM_footer_block b
|
||||
where a.file_sheet_mnemonic='IHTHAM_HAM' and trx_record=1;
|
||||
|
||||
insert into transactional.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
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
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
tyre_details,
|
||||
Tyre_Make,
|
||||
Tyre_size,
|
||||
Ply_Rating::numeric ,
|
||||
Load_Carrying_Capacity,
|
||||
pressure_kg_cm2::numeric ,
|
||||
No_of_lug::numeric,
|
||||
Number_of_no_load_lug_30m::numeric,
|
||||
Lug_Height::numeric,
|
||||
Dynamic_rolling_radius::numeric ,
|
||||
Wheel_rim_Make_size
|
||||
from staging2.IHTHAM_HAM_tyre_details_block where trx_record=1;
|
||||
|
||||
insert into transactional.test_instance_tractor_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model
|
||||
from
|
||||
staging2.IHTHAM_HAM_H1_block where trx_record=1;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set mahindra_model_yn = (
|
||||
case when lower(tractor_make) like 'mahindra%' then 'Y' else 'N' end
|
||||
) where file_syspk =__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info a
|
||||
set test_tractor_yn ='Y' where syspk in
|
||||
(select min(syspk) from transactional.test_instance_tractor_info b
|
||||
where b.file_syspk =a.file_syspk)
|
||||
and a.file_syspk =__file_syspk;
|
||||
|
||||
insert into transactional.test_instance_engine_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
low_idle_declared,
|
||||
low_idle_observed,
|
||||
high_idle_declared,
|
||||
high_idle_observed,
|
||||
rated_rpm,
|
||||
rated_rpm_observed,
|
||||
engine_to_pto_ratio_540_pto
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
low_idle_declared,
|
||||
low_idle_observed::numeric,
|
||||
high_idle_declared,
|
||||
high_idle_observed::numeric,
|
||||
rated_rpm_declared::numeric,
|
||||
rated_rpm_observed::numeric,
|
||||
engine_to_pto_ratio
|
||||
from staging2.IHTHAM_HAM_engine_rpm_block where trx_record=1;
|
||||
|
||||
insert into transactional.test_instance_weight_reaction
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
front_reaction_kg,
|
||||
rear_reaction_kg,
|
||||
total_weight_kg
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
test_condition,
|
||||
Front_weight::numeric,
|
||||
Rear_weight::numeric,
|
||||
Total_weight::numeric
|
||||
from staging2.IHTHAM_HAM_weight_block where trx_record=1;
|
||||
|
||||
|
||||
/*block */
|
||||
|
||||
insert into transactional.test_instance_atmospheric_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
ambient_temp_c,
|
||||
humidity_pct,
|
||||
wind_velocity_kmph,
|
||||
date_of_test,
|
||||
start_time,
|
||||
end_time
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
Ambient_temp_C::numeric ,
|
||||
humidity::numeric ,
|
||||
wind_velocity,
|
||||
date::date,
|
||||
start_time::time,
|
||||
end_time::time
|
||||
from staging2.IHTHAM_HAM_atmos_cond_block where trx_record=1;
|
||||
|
||||
insert into transactional.test_instance_drawbar_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
required_pull_in_kg,
|
||||
required_power_in_hp,
|
||||
actual_pull_in_kg,
|
||||
actual_power_in_hp,
|
||||
calculated_hitch_height_mm,
|
||||
actual_hitch_height_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
test_condition,
|
||||
Required_pull_in_kg::numeric ,
|
||||
Required_Power_in_hp::numeric ,
|
||||
Actual_pull_in_kg::numeric ,
|
||||
actual_power_in_hp::numeric ,
|
||||
Calculated_hitch_heigh_mm::numeric ,
|
||||
Actual_hitch_height_mm::numeric
|
||||
from staging2.IHTHAM_ham_drawbar_block where trx_record=1;
|
||||
|
||||
insert into transactional.IHT_hot_air_mapping_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
gear,
|
||||
load_kg,
|
||||
speed_kmph,
|
||||
speed_rpm,
|
||||
ambient_measured_temp_c,
|
||||
head_measured_temp_c,
|
||||
head_roa_c,
|
||||
chest_measured_temp_c,
|
||||
chest_roa_c,
|
||||
rh_leg_measured_temp_c,
|
||||
rh_leg_roa_c,
|
||||
lh_leg_measured_temp_c,
|
||||
lh_leg_roa_c,
|
||||
rh_hand_measured_temp_c,
|
||||
rh_hand_roa_c,
|
||||
lh_hand_measured_temp_c,
|
||||
lh_hand_roa_c,
|
||||
time_of_test,
|
||||
towards_main_security_gate_yn,
|
||||
time_diff_h_min
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column3,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column10::numeric ,
|
||||
column11::numeric ,
|
||||
column12::numeric ,
|
||||
column13::numeric ,
|
||||
column14::numeric ,
|
||||
column15::numeric ,
|
||||
column16::numeric ,
|
||||
column17::numeric ,
|
||||
column18::numeric ,
|
||||
column19::numeric ,
|
||||
column20::numeric ,
|
||||
column21::numeric ,
|
||||
column22::time ,column23 ,column24::time
|
||||
from staging2.IHTHAM_ham_results_block ihrb where trx_record=1 order by block_row_number;
|
||||
|
||||
|
||||
|
||||
select syspk into __test_instance_id from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_model into __model from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_make into __make from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select syspk from transactional.test_master into __test_master_id where test_type ='In House';
|
||||
select syspk into __test_instance_tractor_id from transactional.test_instance_tractor_info where file_syspk =__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance
|
||||
set test_master_id =__test_master_id,
|
||||
test_tractor_id =__test_instance_tractor_id
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.test_instance_engine_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.test_instance_weight_reaction
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.test_instance_atmospheric_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.test_instance_drawbar_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.IHT_hot_air_mapping_results
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'trx', 'fn_IHTHAM_HAM_TRX', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
855
onetime/dataloadfunctions/IHT/IHT_HAM_STG2.sql
Executable file
855
onetime/dataloadfunctions/IHT/IHT_HAM_STG2.sql
Executable file
@@ -0,0 +1,855 @@
|
||||
drop function if exists staging2.fn_IHTHAM_HAM_block;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTHAM_HAM_block(p_client_id int,p_function_id int, p_file_mnemonic text,p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare err_query int;
|
||||
declare err_block text;
|
||||
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTHAM_HAM_block
|
||||
Function Desc: This function populates data into staging 2 block
|
||||
File Format: IHT
|
||||
Sheet Format: IHTHAM_HAM
|
||||
Creation Date: March 25 2021
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTHAM_HAM_block(p_client_id,p_function_id, p_file_mnemonic,
|
||||
p_file_sheet_mnemonic, p_file_syspk)
|
||||
Function call ex: select staging2.fn_IHTHAM_HAM_block(1,2,'IHT','IHTHAM_HAM',456)
|
||||
***************************************************************/
|
||||
|
||||
|
||||
SET search_path TO staging2;
|
||||
|
||||
/* to process multiple files - re-runnability*/
|
||||
|
||||
truncate table staging2.IHTHAM_HAM_H1_Int;
|
||||
truncate table staging2.IHTHAM_HAM_H1_block;
|
||||
truncate table staging2.IHTHAM_HAM_Tyre_Details_Block;
|
||||
truncate table staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int;
|
||||
truncate table staging2.IHTHAM_HAM_Engine_RPM_Block;
|
||||
truncate table staging2.IHTHAM_HAM_Tractor_Block;
|
||||
truncate table staging2.IHTHAM_HAM_Weight_Block;
|
||||
truncate table staging2.IHTHAM_HAM_Drawbar_Block;
|
||||
truncate table staging2.IHTHAM_HAM_Atmos_Cond_Block;
|
||||
truncate table staging2.IHTHAM_HAM_Results_Block;
|
||||
truncate table staging2.IHTHAM_HAM_Footer_Block;
|
||||
truncate table staging2.stg_specific_table_IHTHAM_HAM;
|
||||
truncate table staging2.stg_process_table_IHTHAM_HAM;
|
||||
|
||||
|
||||
execute 'delete from fw_core.fw_jobctl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=null,
|
||||
row_previous_number=null,
|
||||
row_read_end=null,
|
||||
run_time=null
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* transfer data from generic to specific for IHT */
|
||||
execute 'insert into staging2.stg_specific_table_IHTHAM_HAM
|
||||
select * from staging1.staging_generic_table a
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''
|
||||
and a.file_syspk='||p_file_syspk||'';
|
||||
|
||||
select count(*) into err_query from staging2.stg_specific_table_IHTHAM_HAM;
|
||||
|
||||
if err_query=0 then
|
||||
err_context := 'data not present';
|
||||
raise exception using
|
||||
message = 'No Data for IHT HAM',
|
||||
detail = 'No data in table stg_specific_table_IHTHAM_HAM',
|
||||
errcode = '42704',
|
||||
hint = 'check sheet mnemonic in generic table, if it is null update it';
|
||||
end if;
|
||||
|
||||
/* trimming data */
|
||||
update staging2.stg_specific_table_IHTHAM_HAM set column15='Objective'
|
||||
where lower(column15) like 'objective%';
|
||||
|
||||
update staging2.stg_specific_table_IHTHAM_HAM set column15='Acceptance criteria'
|
||||
where lower(column15) like 'acceptance criteria%';
|
||||
|
||||
|
||||
|
||||
update transactional.source_config set F1_source=F1_modified ;
|
||||
|
||||
|
||||
/* keyword match in config table*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=(select min(b.row_number)
|
||||
from staging2.stg_specific_table_IHTHAM_HAM b
|
||||
where upper(F1_modified)=upper(column3)
|
||||
and b.is_rownumber_fetched is null)
|
||||
where a.row_number_start is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* reverese update in process table for match*/
|
||||
execute 'update staging2.stg_specific_table_IHTHAM_HAM a
|
||||
set is_rownumber_fetched=1
|
||||
from transactional.source_config b
|
||||
where upper(F1_modified)=upper(column3)
|
||||
and b.row_number_start=a.row_number
|
||||
and is_rownumber_fetched is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'update transactional.source_config a set row_previous_number=row_number_start-1
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* update config files for row numbers start, end */
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end= (select b.row_number_start
|
||||
from transactional.source_config b
|
||||
where b.syspk=a.syspk+1 and file_mnemonic='''||p_file_mnemonic||''' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||''' )
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* config file last field update as null otherwise it picks up next format row number*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end = null ,run_time=current_timestamp
|
||||
where f1_modified =''Prepared by''
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* tagging block_row_numbers*/
|
||||
execute 'insert into staging2.stg_process_table_IHTHAM_HAM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTHAM_HAM a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Test Request no.''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTHAM_HAM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTHAM_HAM a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Engine (RPM)''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTHAM_HAM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTHAM_HAM a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Atmospheric condition''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTHAM_HAM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTHAM_HAM a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Gear''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTHAM_HAM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTHAM_HAM a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Prepared By''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/*selecting tractor model*/
|
||||
select column6 into __model from staging2.stg_process_table_IHTHAM_HAM a
|
||||
where block_tag='IHTHAM_HAM_H1' and trim(column3)='Tractor Model';
|
||||
|
||||
/*block starts - IHTHAM_HAM_H1_BLOCK */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTHAM_HAM_H1_BLOCK',__file_mnemonic,__file_sheet_mnemonic,1);
|
||||
err_block:='IHTHAM_HAM_H1_BLOCK';
|
||||
|
||||
insert into staging2.IHTHAM_HAM_H1_INT (c1,c2)
|
||||
select a.column3,column6 from staging2.stg_process_table_IHTHAM_HAM a where block_tag='IHTHAM_HAM_H1';
|
||||
|
||||
insert into staging2.IHTHAM_HAM_H1_INT (c1,c2)
|
||||
select a.column9,column12 from staging2.stg_process_table_IHTHAM_HAM a where block_tag='IHTHAM_HAM_H1';
|
||||
|
||||
insert into staging2.IHTHAM_HAM_H1_INT (c1,c2)
|
||||
select 'Objective',column15
|
||||
from staging2.stg_process_table_IHTHAM_HAM a
|
||||
where block_tag='IHTHAM_HAM_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTHAM_HAM a
|
||||
where column15='Objective'
|
||||
and block_tag='IHTHAM_HAM_H1'
|
||||
);
|
||||
|
||||
insert into staging2.IHTHAM_HAM_H1_INT (c1,c2)
|
||||
select 'Acceptance criteria',column15
|
||||
from staging2.stg_process_table_IHTHAM_HAM a
|
||||
where block_tag='IHTHAM_HAM_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTHAM_HAM a
|
||||
where column15='Acceptance criteria'
|
||||
and block_tag='IHTHAM_HAM_H1'
|
||||
);
|
||||
|
||||
insert into staging2.IHTHAM_HAM_H1_INT (c1,c2)
|
||||
select split_part(column3,':',1),split_part(column3,':',2)
|
||||
from staging2.stg_process_table_IHTHAM_HAM
|
||||
where block_tag='IHTHAM_HAM_Results' and block_row_number=49;
|
||||
|
||||
insert into staging2.IHTHAM_HAM_H1_INT (c1,c2)
|
||||
select column3,column4
|
||||
from staging2.stg_process_table_IHTHAM_HAM
|
||||
where block_tag='IHTHAM_HAM_Atmos_Cond' and block_row_number=4;
|
||||
|
||||
update staging2.IHTHAM_HAM_H1_Int set model=__model;
|
||||
execute 'update staging2.IHTHAM_HAM_H1_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
insert into staging2.IHTHAM_HAM_H1_Block
|
||||
(
|
||||
dummy_f,
|
||||
Test_Request_no,
|
||||
Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Tractor_Model,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date,
|
||||
No_of_Sample,
|
||||
Test_Start_Date,
|
||||
Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Test_standard_refer,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
Remarks,
|
||||
condition
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{c2}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[c2::text]) AS val
|
||||
FROM staging2.IHTHAM_HAM_H1_INT
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,
|
||||
a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,a_18 text,
|
||||
a_19 text,a_20 text);
|
||||
|
||||
update staging2.IHTHAM_HAM_H1_Block
|
||||
set Sample_Receipt_Date=case
|
||||
when Sample_Receipt_Date like '%-%' then Sample_Receipt_Date::timestamptz
|
||||
else date '1899-12-30' + Sample_Receipt_Date::int * interval '1' day
|
||||
end;
|
||||
|
||||
update staging2.IHTHAM_HAM_H1_Block
|
||||
set Test_Report_Date=case
|
||||
when Test_Report_Date like '%-%' then Test_Report_Date::timestamptz
|
||||
else date '1899-12-30' + Test_Report_Date::int * interval '1' day
|
||||
end;
|
||||
|
||||
update staging2.IHTHAM_HAM_H1_Block
|
||||
set Test_Start_Date=case
|
||||
when Test_Report_Date like '%-%' then Test_Report_Date::timestamptz
|
||||
else date '1899-12-30' + Test_Report_Date::int * interval '1' day
|
||||
end;
|
||||
update staging2.IHTHAM_HAM_H1_Block
|
||||
set Test_End_Date=case
|
||||
when Test_Report_Date like '%-%' then Test_Report_Date::timestamptz
|
||||
else date '1899-12-30' + Test_Report_Date::int * interval '1' day
|
||||
end;
|
||||
|
||||
|
||||
delete from staging2.IHTHAM_HAM_H1_Block where dummy_f is null ;
|
||||
update staging2.IHTHAM_HAM_H1_Block set model=__model;
|
||||
execute 'update staging2.IHTHAM_HAM_H1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHAM_HAM_H1_BLOCK');
|
||||
|
||||
insert into staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
(
|
||||
column3,column4,column5,column6,column8,column9 ,
|
||||
column10,column11,column12,column13,
|
||||
column14,column15,column16,column17,
|
||||
column18,column19,column20,column21 ,
|
||||
column22,block_row_number
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column8,column9,
|
||||
column10,column11,column12,column13,
|
||||
column14,column15,column16,column17,
|
||||
column18,column19,column20,column21 ,
|
||||
column22,block_row_number
|
||||
from staging2.stg_process_table_IHTHAM_HAM a
|
||||
where block_tag='IHTHAM_HAM_Engine_Tyre_Weight'
|
||||
order by block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int set model=__model;
|
||||
execute 'update staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/*block starts - IHTHAM_HAM_Tyre_Details_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTHAM_HAM_Tyre_Details_Block',__file_mnemonic,__file_sheet_mnemonic,2);
|
||||
err_block:='IHTHAM_HAM_Tyre_Details_Block';
|
||||
insert into staging2.IHTHAM_HAM_Tyre_Details_Block
|
||||
(
|
||||
dummy_f,
|
||||
Tyre_Details,
|
||||
Tyre_Make,
|
||||
Tyre_size,
|
||||
Ply_Rating,
|
||||
Load_Carrying_Capacity,
|
||||
pressure_kg_cm2,
|
||||
No_of_lug,
|
||||
Number_of_no_load_lug_30m,
|
||||
Lug_Height,
|
||||
Dynamic_rolling_radius,
|
||||
Wheel_rim_Make_size
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column15,column20}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column15::text,column20::text]) AS val
|
||||
FROM staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int where block_row_number between 4 and 14
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,
|
||||
a_8 text,a_9 text,a_10 text,a_11 text);
|
||||
|
||||
|
||||
|
||||
delete from staging2.IHTHAM_HAM_Tyre_Details_Block where dummy_f is null ;
|
||||
update staging2.IHTHAM_HAM_Tyre_Details_Block set model=__model;
|
||||
execute 'update staging2.IHTHAM_HAM_Tyre_Details_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHAM_HAM_Tyre_Details_Block');
|
||||
|
||||
|
||||
/*block starts - IHTHAM_HAM_Engine_RPM_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTHAM_HAM_Engine_RPM_Block',__file_mnemonic,__file_sheet_mnemonic,3);
|
||||
err_block:='IHTHAM_HAM_Engine_RPM_Block';
|
||||
insert into staging2.IHTHAM_HAM_Engine_RPM_Block(dummy_f) values ('dummy');
|
||||
|
||||
update staging2.IHTHAM_HAM_Engine_RPM_Block
|
||||
set low_idle_declared=(select column6 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=2 and column3='Low Idle RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Engine_RPM_Block
|
||||
set low_idle_observed=(select column8 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=2 and column3='Low Idle RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Engine_RPM_Block
|
||||
set high_idle_declared=(select column6 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=3 and column10='High Idle RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Engine_RPM_Block
|
||||
set high_idle_observed=(select column8 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=3 and column3='High Idle RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Engine_RPM_Block
|
||||
set rated_rpm_declared=(select column6 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=4 and column3='Rated RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Engine_RPM_Block
|
||||
set rated_rpm_observed=(select column8 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=4 and column3='Rated RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Engine_RPM_Block
|
||||
set Engine_to_PTO_Ratio=(select column6 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=5 and column3='Engine to PTO Ratio')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update staging2.IHTHAM_HAM_Engine_RPM_Block set model=__model;
|
||||
execute 'update staging2.IHTHAM_HAM_Engine_RPM_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHAM_HAM_Engine_RPM_Block');
|
||||
|
||||
|
||||
/*block starts -IHTHAM_HAM_Drawbar_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTHAM_HAM_Drawbar_Block',__file_mnemonic,__file_sheet_mnemonic,4);
|
||||
err_block:='IHTHAM_HAM_Drawbar_Block';
|
||||
|
||||
|
||||
insert into staging2.IHTHAM_HAM_Drawbar_Block(test_condition)
|
||||
select distinct column6 from staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number between 9 and 14;
|
||||
|
||||
insert into staging2.IHTHAM_HAM_Drawbar_Block(test_condition)
|
||||
select distinct column8 from staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number between 9 and 14;
|
||||
|
||||
update staging2.IHTHAM_HAM_Drawbar_Block
|
||||
set Required_pull_in_kg = (select column7
|
||||
from staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='UB' and block_row_number =9);
|
||||
|
||||
|
||||
update staging2.IHTHAM_HAM_Drawbar_Block
|
||||
set Required_Power_in_hp = (select column7
|
||||
from staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='UB' and block_row_number =10);
|
||||
|
||||
update staging2.IHTHAM_HAM_Drawbar_Block
|
||||
set Actual_pull_in_kg = (select column7
|
||||
from staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='UB' and block_row_number =11);
|
||||
|
||||
|
||||
update staging2.IHTHAM_HAM_Drawbar_Block
|
||||
set actual_power_in_hp = (select column7
|
||||
from staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='UB' and block_row_number =12);
|
||||
|
||||
|
||||
update staging2.IHTHAM_HAM_Drawbar_Block
|
||||
set Calculated_hitch_heigh_mm = (select column7
|
||||
from staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='UB' and block_row_number =13);
|
||||
|
||||
update staging2.IHTHAM_HAM_Drawbar_Block
|
||||
set Actual_hitch_height_mm = (select column7
|
||||
from staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='UB' and block_row_number =14);
|
||||
|
||||
update staging2.IHTHAM_HAM_Drawbar_Block
|
||||
set Required_pull_in_kg = (select column9
|
||||
from staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='B' and block_row_number =9);
|
||||
|
||||
|
||||
update staging2.IHTHAM_HAM_Drawbar_Block
|
||||
set Required_Power_in_hp = (select column9
|
||||
from staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='B' and block_row_number =10);
|
||||
|
||||
update staging2.IHTHAM_HAM_Drawbar_Block
|
||||
set Actual_pull_in_kg = (select column9
|
||||
from staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='B' and block_row_number =11);
|
||||
|
||||
|
||||
update staging2.IHTHAM_HAM_Drawbar_Block
|
||||
set actual_power_in_hp = (select column9
|
||||
from staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='B' and block_row_number =12);
|
||||
|
||||
|
||||
update staging2.IHTHAM_HAM_Drawbar_Block
|
||||
set Calculated_hitch_heigh_mm = (select column9
|
||||
from staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='B' and block_row_number =13);
|
||||
|
||||
update staging2.IHTHAM_HAM_Drawbar_Block
|
||||
set Actual_hitch_height_mm = (select column9
|
||||
from staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='B' and block_row_number =14);
|
||||
|
||||
update staging2.IHTHAM_HAM_Drawbar_Block set model=__model;
|
||||
execute 'update staging2.IHTHAM_HAM_Drawbar_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHAM_HAM_Drawbar_Block');
|
||||
|
||||
|
||||
|
||||
/*block starts - IHTHAM_HAM_Tractor_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTHAM_HAM_Tractor_Block',__file_mnemonic,__file_sheet_mnemonic,5);
|
||||
err_block:='IHTHAM_HAM_Tractor_Block';
|
||||
|
||||
insert into staging2.IHTHAM_HAM_Tractor_Block(dummy_f) values ('dummy');
|
||||
|
||||
update staging2.IHTHAM_HAM_Tractor_Block
|
||||
set Wheel_Base_mm=(select column6 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=5 and column3='Wheel Base (mm)')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update staging2.IHTHAM_HAM_Tractor_Block
|
||||
set Engine_Power_hp=(select column6 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=6 and column3='Engine Power hp')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Tractor_Block
|
||||
set PTO_Power_hp=(select column6 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=7 and column3='PTO Power hp')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update staging2.IHTHAM_HAM_Tractor_Block set model=__model;
|
||||
execute 'update staging2.IHTHAM_HAM_Tractor_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHAM_HAM_Tractor_Block');
|
||||
|
||||
/*block starts -IHTHAM_HAM_Weight_Block*/
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTHAM_HAM_Weight_Block',__file_mnemonic,__file_sheet_mnemonic,6);
|
||||
err_block:='IHTHAM_HAM_Weight_Block';
|
||||
|
||||
insert into staging2.IHTHAM_HAM_Weight_Block(dummy_f) values ('dummy');
|
||||
|
||||
update staging2.IHTHAM_HAM_Weight_Block
|
||||
set test_condition=(select column10 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=2 )
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Weight_Block
|
||||
set test_condition=(select column10 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=3)
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Weight_Block
|
||||
set Front_weight=(select column13 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=2 and column14='Unballast')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Weight_Block
|
||||
set Front_weight=(select column13 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=3 and column14='Ballast')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Weight_Block
|
||||
set Rear_weight=(select column17 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=2 and column14='Unballast')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Weight_Block
|
||||
set Rear_weight=(select column17 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=3 and column14='Ballast')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Weight_Block
|
||||
set Total_weight=(select column21 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=2 and column14='Unballast')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Weight_Block
|
||||
set Total_weight=(select column21 from
|
||||
staging2.IHTHAM_HAM_Engine_Tyre_Weight_Int
|
||||
where block_row_number=3 and column14='Ballast')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update staging2.IHTHAM_HAM_Weight_Block set model=__model;
|
||||
execute 'update staging2.IHTHAM_HAM_Weight_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHAM_HAM_Weight_Block');
|
||||
|
||||
|
||||
/*block starts - IHTHAM_HAM_Atmos_Cond_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTHAM_HAM_Atmos_Cond_Block',__file_mnemonic,__file_sheet_mnemonic,7);
|
||||
err_block:='IHTHAM_HAM_Atmos_Cond_Block';
|
||||
insert into staging2.IHTHAM_HAM_Atmos_Cond_Block
|
||||
(
|
||||
dummy_f,
|
||||
Ambient_temp_C,
|
||||
humidity,
|
||||
wind_velocity
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column5}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column5::text]) AS val
|
||||
FROM staging2.stg_process_table_ihtham_ham
|
||||
where block_tag=''IHTHAM_HAM_Atmos_Cond'' and block_row_number in (1,2,3)
|
||||
ORDER BY generate_series(1,15),block_row_number,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text);
|
||||
|
||||
update staging2.IHTHAM_HAM_Atmos_Cond_Block
|
||||
set date=
|
||||
(select date '1899-12-30' + column8::int * interval '1' day
|
||||
FROM staging2.stg_process_table_ihtham_ham
|
||||
where column7='Date' and block_tag='IHTHAM_HAM_Atmos_Cond' and block_row_number =1);
|
||||
|
||||
update staging2.IHTHAM_HAM_Atmos_Cond_Block
|
||||
set start_time=
|
||||
(select to_char(to_timestamp((column8::numeric)* 60),'HH12:MI')
|
||||
FROM staging2.stg_process_table_ihtham_ham
|
||||
where column7='Start Time' and block_tag='IHTHAM_HAM_Atmos_Cond' and block_row_number=2);
|
||||
|
||||
update staging2.IHTHAM_HAM_Atmos_Cond_Block
|
||||
set end_time=
|
||||
(select to_char(to_timestamp((column8::numeric)* 60),'HH12:MI')
|
||||
FROM staging2.stg_process_table_ihtham_ham
|
||||
where column7='End time' and block_tag='IHTHAM_HAM_Atmos_Cond' and block_row_number=3);
|
||||
|
||||
|
||||
|
||||
delete from staging2.IHTHAM_HAM_Atmos_Cond_Block where dummy_f is null ;
|
||||
update staging2.IHTHAM_HAM_Atmos_Cond_Block set model=__model;
|
||||
execute 'update staging2.IHTHAM_HAM_Atmos_Cond_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHAM_HAM_Atmos_Cond_Block');
|
||||
|
||||
|
||||
/*block starts - IHTHAM_HAM_Results_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTHAM_HAM_Results_Block',__file_mnemonic,__file_sheet_mnemonic,8);
|
||||
err_block:='IHTHAM_HAM_Results_Block';
|
||||
insert into staging2.IHTHAM_HAM_Results_Block
|
||||
(
|
||||
column3,column4,column5,column6,
|
||||
column7,column8,column9,
|
||||
column10,column11,column12,
|
||||
column13,column14,column15,
|
||||
column16,column17,column18,
|
||||
column19,column20,column21,
|
||||
column22,column23,column24,block_row_number
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,
|
||||
column7,column8,column9,
|
||||
column10,column11,column12,
|
||||
column13,column14,column15,
|
||||
column16,column17,column18,
|
||||
column19,column20,column21,
|
||||
column22,column23,column24,block_row_number
|
||||
from staging2.stg_process_table_IHTHAM_HAM a
|
||||
where block_tag='IHTHAM_HAM_Results'
|
||||
order by block_row_number;
|
||||
|
||||
|
||||
|
||||
update staging2.IHTHAM_HAM_Results_Block
|
||||
set trx_record =0 where block_row_number in (1,2,49,50,51);
|
||||
|
||||
update staging2.ihtham_ham_results_block a
|
||||
set column3= b.first_value from (SELECT
|
||||
block_row_number, column3, value_partition, first_value(column3) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column3,
|
||||
sum(case when column3 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.ihtham_ham_results_block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number = b.block_row_number;
|
||||
|
||||
update staging2.IHTHAM_HAM_Results_Block
|
||||
set column22= to_char((column22::numeric) * '24 hours'::interval,'HH12:MIPM')
|
||||
where trx_record=1;
|
||||
|
||||
--select to_char((3.4722222222222654E-3) * '24 hours'::interval,'HH12:MI')
|
||||
|
||||
--select to_timestamp(cast('3.4722222222222654E-3' as real));
|
||||
|
||||
update staging2.IHTHAM_HAM_Results_Block
|
||||
set column24= to_char((cast(column24 as real)) * '24 hours'::interval,'HH24:MI')
|
||||
where trx_record=1;
|
||||
|
||||
|
||||
update staging2.IHTHAM_HAM_Results_Block set model=__model;
|
||||
execute 'update staging2.IHTHAM_HAM_Results_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHAM_HAM_Results_Block');
|
||||
|
||||
/*block starts - IHTHAM_HAM_Footer_block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTHAM_HAM_Footer_block',__file_mnemonic,__file_sheet_mnemonic,9);
|
||||
err_block:='IHTHAM_HAM_Footer_block';
|
||||
|
||||
insert into staging2.IHTHAM_HAM_Footer_block(dummy_f) values ('dummy');
|
||||
|
||||
update staging2.IHTHAM_HAM_Footer_block a
|
||||
set prepared_by=( select column7 from staging2.stg_process_table_IHTHAM_HAM b
|
||||
where b.block_tag='IHTHAM_HAM_Footer'
|
||||
and lower(column3)='prepared by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Footer_block a
|
||||
set reviewed_by=( select column7 from staging2.stg_process_table_IHTHAM_HAM b
|
||||
where b.block_tag='IHTHAM_HAM_Footer'
|
||||
and lower(column3)='reviewed by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Footer_block a
|
||||
set approved_by=( select column7 from staging2.stg_process_table_IHTHAM_HAM b
|
||||
where b.block_tag='IHTHAM_HAM_Footer'
|
||||
and lower(column3)='approved by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Footer_block a
|
||||
set comments=( select column3 from staging2.stg_process_table_IHTHAM_HAM b
|
||||
where b.block_tag='IHTHAM_HAM_Footer'
|
||||
and block_row_number=5 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Footer_block a
|
||||
set rev1=( select column3 from staging2.stg_process_table_IHTHAM_HAM b
|
||||
where b.block_tag='IHTHAM_HAM_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
update staging2.IHTHAM_HAM_Footer_block a
|
||||
set rev2=( select column9 from staging2.stg_process_table_IHTHAM_HAM b
|
||||
where b.block_tag='IHTHAM_HAM_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Footer_block a
|
||||
set rev3=( select column18 from staging2.stg_process_table_IHTHAM_HAM b
|
||||
where b.block_tag='IHTHAM_HAM_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
|
||||
update staging2.IHTHAM_HAM_Footer_block a
|
||||
set replaces=( select column23 from staging2.stg_process_table_IHTHAM_HAM b
|
||||
where b.block_tag='IHTHAM_HAM_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Footer_block a
|
||||
set revision_no=( select column23 from staging2.stg_process_table_IHTHAM_HAM b
|
||||
where b.block_tag='IHTHAM_HAM_Footer'
|
||||
and block_row_number=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Footer_block a
|
||||
set prepared_date=( select column19 from staging2.stg_process_table_IHTHAM_HAM b
|
||||
where b.block_tag='IHTHAM_HAM_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Footer_block a
|
||||
set reviewed_date=( select column19 from staging2.stg_process_table_IHTHAM_HAM b
|
||||
where b.block_tag='IHTHAM_HAM_Footer'
|
||||
and block_row_number=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Footer_block a
|
||||
set approved_date=( select column19 from staging2.stg_process_table_IHTHAM_HAM b
|
||||
where b.block_tag='IHTHAM_HAM_Footer'
|
||||
and block_row_number=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHAM_HAM_Footer_block set model=__model;
|
||||
execute 'update staging2.IHTHAM_HAM_Footer_block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHAM_HAM_Footer_block');
|
||||
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'stg2', 'fn_IHTHAM_HAM_block', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
|
||||
306
onetime/dataloadfunctions/IHT/IHT_HLS_ODS.sql
Executable file
306
onetime/dataloadfunctions/IHT/IHT_HLS_ODS.sql
Executable file
@@ -0,0 +1,306 @@
|
||||
drop function if exists staging2.fn_IHTHLS_HLS_TRX;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTHLS_HLS_TRX(p_client_id int,p_function_id int, p_file_mnemonic text,
|
||||
p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __test_instance_id int;
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare _error int;
|
||||
declare __test_master_id int;
|
||||
declare __test_instance_tractor_id int;
|
||||
begin
|
||||
|
||||
__file_syspk := p_file_syspk;
|
||||
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTHLS_HLS_TRX
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHTHLS
|
||||
Sheet Format: IHTHLS_HLS
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTHLS_HLS_TRX()
|
||||
***************************************************************/
|
||||
insert into transactional.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
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,
|
||||
objective_of_test,
|
||||
acceptance_criteria,
|
||||
remarks,
|
||||
test_purpose
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
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,
|
||||
to_date(Test_Start_Date,'DD-MM-YYYY'),
|
||||
to_date(Test_End_Date, 'DD-MM-YYYY'),
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_Location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
Remarks,
|
||||
Test_Purpose
|
||||
from staging2.IHTHLS_HLS_H1_block where trx_record=1;
|
||||
|
||||
update transactional.test_instance a
|
||||
set
|
||||
report_prepared_date=to_date(b.prepared_date,'DD-MM-YYYY'),
|
||||
report_reviewed_date=to_date(b.reviewed_date,'DD-MM-YYYY'),
|
||||
report_approved_date=to_date(b.approved_date,'DD-MM-YYYY'),
|
||||
report_prepared_by=b.prepared_by,
|
||||
report_reviewed_by=b.reviewed_by,
|
||||
report_approved_by=b.approved_by,
|
||||
report_template_replaces=b.replaces,
|
||||
report_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from staging2.IHTHLS_HLS_footer_block b
|
||||
where a.file_sheet_mnemonic ='IHTHLS_HLS' and trx_record=1;
|
||||
|
||||
insert into transactional.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tyre_type,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
tyre_ply_rating,
|
||||
tyre_load_carrying_capacity,
|
||||
tyre_pressure_kg_per_cm2,
|
||||
tyre_static_rolling_radius_mm,
|
||||
tyre_dynamic_rolling_radius_mm,
|
||||
tyre_wheel_rim_make_and_size
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
tyre_details,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
ply_rating::numeric,
|
||||
load_carrying_capacity,
|
||||
Pressure_kg_cm2::numeric ,
|
||||
Dynamic_rolling_radius::numeric ,
|
||||
Static_rolling_radius::numeric ,
|
||||
wheel_rim_make_size
|
||||
from staging2.IHTHLS_HLS_tyre_details_block where trx_record=1;
|
||||
|
||||
insert into transactional.test_instance_tractor_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
wheel_base_mm,
|
||||
rear_track_width_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
wheel_base::numeric ,
|
||||
rear_track_width::numeric
|
||||
from staging2.IHTHLS_hls_wheel_block where trx_record=1;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set mahindra_model_yn = (
|
||||
case when tractor_make like 'Mahindra%' then 'Y' else 'N' end
|
||||
) where file_syspk =__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info a
|
||||
set test_tractor_yn ='Y' where syspk in
|
||||
(select min(syspk) from transactional.test_instance_tractor_info b
|
||||
where b.file_syspk =a.file_syspk)
|
||||
and a.file_syspk =__file_syspk;
|
||||
|
||||
|
||||
|
||||
/*block */
|
||||
|
||||
insert into transactional.test_instance_weight_reaction
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
total_weight_kg,
|
||||
front_reaction_kg,
|
||||
rear_reaction_kg,
|
||||
left_reaction_fl_rl_kg,
|
||||
right_reaction_fr_rr_kg,
|
||||
front_left_reaction_kg,
|
||||
front_right_reactionkg,
|
||||
rear_left_reaction_kg,
|
||||
rear_right_reactionkg,
|
||||
distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg::numeric,
|
||||
Front_Reaction_kg::numeric ,
|
||||
Rear_Reaction_kg::numeric ,
|
||||
Left_Reaction_FL_RL_kg::numeric ,
|
||||
Right_reaction_FR_RR_kg::numeric ,
|
||||
Front_Left_Reaction_kg::numeric ,
|
||||
Front_Right_Reaction_kg::numeric ,
|
||||
Rear_Left_Reaction_kg::numeric ,
|
||||
Rear_Right_Reaction_kg::numeric ,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1::numeric
|
||||
from staging2.IHTHLS_hls_weight_block where trx_record=1;
|
||||
|
||||
|
||||
insert into transactional.IHT_hyd_lift_sensitivity
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tpl_load,
|
||||
engine_rpm_type,
|
||||
lifting_time_sec,
|
||||
lowering_time_sec
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
TPL_load,
|
||||
Engine_RPM,
|
||||
Lifting_time_Sec::numeric ,
|
||||
Lowering_time_Sec::numeric
|
||||
from staging2.IHTHLS_hls_numeric_block where trx_record=1;
|
||||
|
||||
|
||||
select syspk into __test_instance_id from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_model into __model from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_make into __make from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select syspk from transactional.test_master into __test_master_id where test_type ='In House';
|
||||
select syspk into __test_instance_tractor_id from transactional.test_instance_tractor_info where file_syspk =__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance
|
||||
set test_master_id =__test_master_id,
|
||||
test_tractor_id =__test_instance_tractor_id
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_weight_reaction
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.IHT_hyd_lift_sensitivity
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'trx', 'fn_IHTHLS_HLS_TRX', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
|
||||
571
onetime/dataloadfunctions/IHT/IHT_HLS_STG2.sql
Executable file
571
onetime/dataloadfunctions/IHT/IHT_HLS_STG2.sql
Executable file
@@ -0,0 +1,571 @@
|
||||
drop function if exists staging2.fn_IHTHLS_HLS_block;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTHLS_HLS_block(p_client_id int,p_function_id int, p_file_mnemonic text,p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare err_query int;
|
||||
declare err_block text;
|
||||
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTHLS_HLS_block
|
||||
Function Desc: This function populates data into staging 2 block
|
||||
File Format: IHTHLS
|
||||
Sheet Format: IHTHLS_HLS
|
||||
Creation Date: March 25 2021
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTHLS_HLS_block(p_client_id,p_function_id, p_file_mnemonic,
|
||||
p_file_sheet_mnemonic, p_file_syspk)
|
||||
Function call ex: select staging2.fn_IHTHLS_HLS_block(1,2,'IHTHLS','IHTHLS_HLS',456)
|
||||
***************************************************************/
|
||||
|
||||
|
||||
SET search_path TO staging2;
|
||||
|
||||
/* to process multiple files - re-runnability*/
|
||||
|
||||
truncate table staging2.IHTHLS_HLS_H1_Int;
|
||||
truncate table staging2.IHTHLS_HLS_H1_block;
|
||||
truncate table staging2.IHTHLS_HLS_Weight_Tyre_Int;
|
||||
truncate table staging2.IHTHLS_HLS_Weight_Block;
|
||||
truncate table staging2.IHTHLS_HLS_Wheel_Block;
|
||||
truncate table staging2.IHTHLS_HLS_Numeric_Int;
|
||||
truncate table staging2.IHTHLS_HLS_Numeric_Block;
|
||||
truncate table staging2.IHTHLS_HLS_Tyre_Details_Block;
|
||||
truncate table staging2.IHTHLS_HLS_Footer_Block;
|
||||
truncate table staging2.stg_specific_table_IHTHLS_HLS;
|
||||
truncate table staging2.stg_process_table_IHTHLS_HLS;
|
||||
|
||||
|
||||
execute 'delete from fw_core.fw_jobctl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=null,
|
||||
row_previous_number=null,
|
||||
row_read_end=null,
|
||||
run_time=null
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* transfer data from generic to specific for IHTHLS */
|
||||
execute 'insert into staging2.stg_specific_table_IHTHLS_HLS
|
||||
select * from staging1.staging_generic_table a
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''
|
||||
and a.file_syspk='||p_file_syspk||'';
|
||||
|
||||
select count(*) into err_query from staging2.stg_specific_table_IHTHLS_HLS;
|
||||
|
||||
if err_query=0 then
|
||||
err_context := 'data not present';
|
||||
raise exception using
|
||||
message = 'No Data for IHTHLS ',
|
||||
detail = 'No data in table stg_specific_table_IHTHLS_HLS',
|
||||
errcode = '42704',
|
||||
hint = 'check sheet mnemonic in generic table, if it is null update it';
|
||||
end if;
|
||||
|
||||
/* trimming data */
|
||||
update staging2.stg_specific_table_IHTHLS_HLS
|
||||
set column15='Objective' where lower(column15) like 'objective%';
|
||||
|
||||
update staging2.stg_specific_table_IHTHLS_HLS
|
||||
set column15='Acceptance criteria' where lower(column15) like 'acceptance criteria%';
|
||||
|
||||
|
||||
update transactional.source_config set F1_source=F1_modified ;
|
||||
|
||||
|
||||
/* keyword match in config table*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=(select min(b.row_number)
|
||||
from staging2.stg_specific_table_IHTHLS_HLS b
|
||||
where upper(F1_modified)=upper(column3)
|
||||
and b.is_rownumber_fetched is null)
|
||||
where a.row_number_start is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* reverese update in process table for match*/
|
||||
execute 'update staging2.stg_specific_table_IHTHLS_HLS a
|
||||
set is_rownumber_fetched=1
|
||||
from transactional.source_config b
|
||||
where upper(F1_modified)=upper(column3)
|
||||
and b.row_number_start=a.row_number
|
||||
and is_rownumber_fetched is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'update transactional.source_config a set row_previous_number=row_number_start-1
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* update config files for row numbers start, end */
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end= (select b.row_number_start
|
||||
from transactional.source_config b
|
||||
where b.syspk=a.syspk+1 and file_mnemonic='''||p_file_mnemonic||''' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||''' )
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* config file last field update as null otherwise it picks up next format row number*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end = null ,run_time=current_timestamp
|
||||
where f1_modified =''Prepared by''
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* tagging block_row_numbers*/
|
||||
execute 'insert into staging2.stg_process_table_IHTHLS_HLS
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTHLS_HLS a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Test Request no.''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTHLS_HLS
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTHLS_HLS a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Weight Reaction''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTHLS_HLS
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTHLS_HLS a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Numerical data''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTHLS_HLS
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTHLS_HLS a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Prepared By''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/*selecting tractor model*/
|
||||
select column6 into __model from staging2.stg_process_table_IHTHLS_HLS a
|
||||
where block_tag='IHTHLS_HLS_H1' and trim(column3)='Tractor Model';
|
||||
|
||||
/*block starts - IHTHLS_HLS_H1_BLOCK */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTHLS_HLS_H1_BLOCK',__file_mnemonic,__file_sheet_mnemonic,1);
|
||||
err_block:='IHTHLS_HLS_H1_BLOCK';
|
||||
|
||||
insert into staging2.IHTHLS_HLS_H1_INT (c1,c2)
|
||||
select a.column3,column6 from staging2.stg_process_table_IHTHLS_HLS a where block_tag='IHTHLS_HLS_H1';
|
||||
|
||||
insert into staging2.IHTHLS_HLS_H1_INT (c1,c2)
|
||||
select a.column9,column12 from staging2.stg_process_table_IHTHLS_HLS a where block_tag='IHTHLS_HLS_H1';
|
||||
|
||||
insert into staging2.IHTHLS_HLS_H1_INT (c1,c2)
|
||||
select 'Objective',column15
|
||||
from staging2.stg_process_table_IHTHLS_HLS a
|
||||
where block_tag='IHTHLS_HLS_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTHLS_HLS a
|
||||
where column15='Objective'
|
||||
and block_tag='IHTHLS_HLS_H1'
|
||||
);
|
||||
|
||||
insert into staging2.IHTHLS_HLS_H1_INT (c1,c2)
|
||||
select 'Acceptance criteria',column15
|
||||
from staging2.stg_process_table_IHTHLS_HLS a
|
||||
where block_tag='IHTHLS_HLS_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTHLS_HLS a
|
||||
where column15='Acceptance criteria'
|
||||
and block_tag='IHTHLS_HLS_H1'
|
||||
);
|
||||
|
||||
|
||||
|
||||
insert into staging2.IHTHLS_HLS_H1_INT (c1,c2)
|
||||
select split_part(column3,':',1),split_part(column3,':',2)
|
||||
from staging2.stg_process_table_IHTHLS_HLS
|
||||
where block_tag='IHTHLS_HLS_Numeric' and block_row_number=6;
|
||||
|
||||
insert into staging2.IHTHLS_HLS_H1_INT (c1,c2)
|
||||
select 'Test Purpose',column10
|
||||
from staging2.stg_process_table_IHTHLS_HLS a
|
||||
where block_tag='IHTHLS_HLS_Weight_Tyre' and column3='Test Purpose';
|
||||
|
||||
|
||||
update staging2.IHTHLS_HLS_H1_Int set model=__model;
|
||||
execute 'update staging2.IHTHLS_HLS_H1_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
insert into staging2.IHTHLS_HLS_H1_Block
|
||||
(
|
||||
dummy_f,
|
||||
Test_Request_no,
|
||||
Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Tractor_Model,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date,
|
||||
No_of_Sample,
|
||||
Test_Start_Date,
|
||||
Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_Location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
Remarks,
|
||||
Test_Purpose
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{c2}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[c2::text]) AS val
|
||||
FROM staging2.IHTHLS_HLS_H1_INT
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,
|
||||
a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,
|
||||
a_18 text,a_19 text,a_20 text);
|
||||
|
||||
|
||||
delete from staging2.IHTHLS_HLS_H1_Block where dummy_f is null ;
|
||||
update staging2.IHTHLS_HLS_H1_Block set model=__model;
|
||||
execute 'update staging2.IHTHLS_HLS_H1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHLS_HLS_H1_Block');
|
||||
|
||||
|
||||
insert into staging2.IHTHLS_HLS_Weight_Tyre_Int
|
||||
(
|
||||
column3,column6,column10,column13,column15,column17,column19,
|
||||
column20,block_row_number
|
||||
)
|
||||
select
|
||||
column3,column6,column10,column13,column15,column17,column19,
|
||||
column20,block_row_number
|
||||
from staging2.stg_process_table_IHTHLS_HLS a
|
||||
where block_tag='IHTHLS_HLS_Weight_Tyre'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTHLS_HLS_Weight_Tyre_Int set model=__model;
|
||||
execute 'update staging2.IHTHLS_HLS_Weight_Tyre_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
/*block starts - IHTHLS_HLS_Weight_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTHLS_HLS_Weight_Block',__file_mnemonic,__file_sheet_mnemonic,2);
|
||||
err_block:='IHTHLS_HLS_Weight_Block';
|
||||
insert into staging2.IHTHLS_HLS_Weight_Block
|
||||
(
|
||||
dummy_f,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg,
|
||||
Front_Reaction_kg,
|
||||
Rear_Reaction_kg,
|
||||
Left_Reaction_FL_RL_kg,
|
||||
Right_reaction_FR_RR_kg,
|
||||
Front_Left_Reaction_kg,
|
||||
Front_Right_Reaction_kg,
|
||||
Rear_Left_Reaction_kg,
|
||||
Rear_Right_Reaction_kg,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column6}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column6::text]) AS val
|
||||
FROM staging2.IHTHLS_HLS_Weight_Tyre_Int
|
||||
ORDER BY generate_series(1,15),block_row_number,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text,
|
||||
a_10 text,a_11 text);
|
||||
|
||||
delete from staging2.IHTHLS_HLS_Weight_Block where dummy_f is null ;
|
||||
update staging2.IHTHLS_HLS_Weight_Block set model=__model;
|
||||
execute 'update staging2.IHTHLS_HLS_Weight_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHLS_HLS_Weight_Block');
|
||||
|
||||
/*block starts - IHTHLS_HLS_Tyre_Details_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTHLS_HLS_Tyre_Details_Block',__file_mnemonic,__file_sheet_mnemonic,3);
|
||||
err_block:='IHTHLS_HLS_Tyre_Details_Block';
|
||||
insert into staging2.IHTHLS_HLS_Tyre_Details_Block
|
||||
(
|
||||
dummy_f,
|
||||
Tyre_Details,
|
||||
Tyre_Make,
|
||||
Tyre_size,
|
||||
Ply_Rating,
|
||||
Load_Carrying_Capacity,
|
||||
Pressure_kg_cm2,
|
||||
Dynamic_rolling_radius,
|
||||
Static_rolling_radius,
|
||||
Wheel_rim_Make_size
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column15,column19}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column15::text,column19::text]) AS val
|
||||
FROM staging2.IHTHLS_HLS_Weight_Tyre_Int where block_row_number between 3 and 11
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text);
|
||||
|
||||
delete from staging2.IHTHLS_HLS_Tyre_Details_Block where dummy_f is null ;
|
||||
update staging2.IHTHLS_HLS_Tyre_Details_Block set model=__model;
|
||||
execute 'update staging2.IHTHLS_HLS_Tyre_Details_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHLS_HLS_Tyre_Details_Block');
|
||||
|
||||
|
||||
/*block starts - IHTHLS_HLS_Wheel_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTHLS_HLS_Wheel_Block',__file_mnemonic,__file_sheet_mnemonic,4);
|
||||
err_block:='IHTHLS_HLS_Wheel_Block';
|
||||
insert into staging2.IHTHLS_HLS_Wheel_Block(dummy_f) values ('dummy');
|
||||
|
||||
update staging2.IHTHLS_HLS_Wheel_Block
|
||||
set Wheel_Base=(select column13 from
|
||||
staging2.IHTHLS_HLS_Weight_Tyre_Int
|
||||
where block_row_number=1 and column10='Wheel Base in mm')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTHLS_HLS_Wheel_Block
|
||||
set Rear_Track_Width=(select column20 from
|
||||
staging2.IHTHLS_HLS_Weight_Tyre_Int
|
||||
where block_row_number=1 and column17='Rear Track Width in mm')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update staging2.IHTHLS_HLS_Wheel_Block set model=__model;
|
||||
execute 'update staging2.IHTHLS_HLS_Wheel_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHLS_HLS_Wheel_Block');
|
||||
|
||||
|
||||
/* insert IHTHLS_HLS_Numeric_Int*/
|
||||
|
||||
insert into staging2.IHTHLS_HLS_Numeric_Int
|
||||
(
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,block_row_number
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,block_row_number
|
||||
from staging2.stg_process_table_IHTHLS_HLS a
|
||||
where block_tag='IHTHLS_HLS_Numeric'
|
||||
order by block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTHLS_HLS_Numeric_Int set model=__model;
|
||||
execute 'update staging2.IHTHLS_HLS_Numeric_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
update staging2.IHTHLS_HLS_Numeric_Int set trx_record =0 where block_row_number in (1,6);
|
||||
|
||||
|
||||
/*block starts - IHTHLS_HLS_Numeric_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTHLS_HLS_Numeric_Block',__file_mnemonic,__file_sheet_mnemonic,5);
|
||||
err_block:='IHTHLS_HLS_Numeric_Block';
|
||||
insert into staging2.IHTHLS_HLS_Numeric_Block
|
||||
(
|
||||
dummy_f,
|
||||
TPL_load,
|
||||
Engine_RPM,
|
||||
Lifting_time_Sec,
|
||||
Lowering_time_Sec
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column5,column6,column8}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column5::text,column6::text,column8::text]) AS val
|
||||
FROM staging2.IHTHLS_HLS_Numeric_Int
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text);
|
||||
|
||||
update staging2.IHTHLS_hls_numeric_block a
|
||||
set TPL_load= b.first_value from (SELECT
|
||||
block_row_number,TPL_load, value_partition, first_value(TPL_load) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
TPL_load,
|
||||
sum(case when TPL_load is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTHLS_hls_numeric_block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b;
|
||||
|
||||
delete from staging2.IHTHLS_HLS_Numeric_Block where dummy_f is null;
|
||||
update staging2.IHTHLS_HLS_Numeric_Block set model=__model;
|
||||
execute 'update staging2.IHTHLS_HLS_Numeric_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHLS_HLS_Numeric_Block');
|
||||
|
||||
/*block starts - IHTHLS_HLS_Footer_block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTHLS_HLS_Footer_block',__file_mnemonic,__file_sheet_mnemonic,6);
|
||||
err_block:='IHTHLS_HLS_Footer_block';
|
||||
insert into staging2.IHTHLS_HLS_Footer_block(dummy_f) values ('dummy');
|
||||
|
||||
update staging2.IHTHLS_HLS_Footer_block a
|
||||
set prepared_by=( select column7 from staging2.stg_process_table_IHTHLS_HLS b
|
||||
where b.block_tag='IHTHLS_HLS_Footer'
|
||||
and lower(column3)='prepared by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHLS_HLS_Footer_block a
|
||||
set reviewed_by=( select column7 from staging2.stg_process_table_IHTHLS_HLS b
|
||||
where b.block_tag='IHTHLS_HLS_Footer'
|
||||
and lower(column3)='reviewed by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHLS_HLS_Footer_block a
|
||||
set approved_by=( select column7 from staging2.stg_process_table_IHTHLS_HLS b
|
||||
where b.block_tag='IHTHLS_HLS_Footer'
|
||||
and lower(column3)='approved by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHLS_HLS_Footer_block a
|
||||
set comments=( select column3 from staging2.stg_process_table_IHTHLS_HLS b
|
||||
where b.block_tag='IHTHLS_HLS_Footer'
|
||||
and block_row_number=5 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHLS_HLS_Footer_block a
|
||||
set rev1=( select column3 from staging2.stg_process_table_IHTHLS_HLS b
|
||||
where b.block_tag='IHTHLS_HLS_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
update staging2.IHTHLS_HLS_Footer_block a
|
||||
set rev2=( select column9 from staging2.stg_process_table_IHTHLS_HLS b
|
||||
where b.block_tag='IHTHLS_HLS_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHLS_HLS_Footer_block a
|
||||
set rev3=( select column18 from staging2.stg_process_table_IHTHLS_HLS b
|
||||
where b.block_tag='IHTHLS_HLS_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHLS_HLS_Footer_block a
|
||||
set replaces=( select column19 from staging2.stg_process_table_IHTHLS_HLS b
|
||||
where b.block_tag='IHTHLS_HLS_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHLS_HLS_Footer_block a
|
||||
set revision_no=( select column19 from staging2.stg_process_table_IHTHLS_HLS b
|
||||
where b.block_tag='IHTHLS_HLS_Footer'
|
||||
and block_row_number=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHLS_HLS_Footer_block a
|
||||
set prepared_date=( select column16 from staging2.stg_process_table_IHTHLS_HLS b
|
||||
where b.block_tag='IHTHLS_HLS_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHLS_HLS_Footer_block a
|
||||
set reviewed_date=( select column16 from staging2.stg_process_table_IHTHLS_HLS b
|
||||
where b.block_tag='IHTHLS_HLS_Footer'
|
||||
and block_row_number=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHLS_HLS_Footer_block a
|
||||
set approved_date=( select column16 from staging2.stg_process_table_IHTHLS_HLS b
|
||||
where b.block_tag='IHTHLS_HLS_Footer'
|
||||
and block_row_number=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTHLS_HLS_Footer_block set model=__model;
|
||||
execute 'update staging2.IHTHLS_HLS_Footer_block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHLS_HLS_Footer_block');
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'stg2', 'fn_IHTHLS_HLS_block', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
603
onetime/dataloadfunctions/IHT/IHT_NST_ODS.sql
Executable file
603
onetime/dataloadfunctions/IHT/IHT_NST_ODS.sql
Executable file
@@ -0,0 +1,603 @@
|
||||
drop function if exists staging2.fn_IHTNST_NST_TRX;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTNST_NST_TRX(p_client_id int,p_function_id int, p_file_mnemonic text,
|
||||
p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __test_instance_id int;
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare _error int;
|
||||
declare __test_master_id int;
|
||||
declare __test_instance_tractor_id int;
|
||||
begin
|
||||
__file_syspk := p_file_syspk;
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTNST_NST_TRX
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHTNST
|
||||
Sheet Format: IHTNST_NST
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTNST_NST_TRX()
|
||||
***************************************************************/
|
||||
insert into transactional.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
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,
|
||||
objective_of_test,
|
||||
test_condition,
|
||||
test_purpose
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
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_facility,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
condition,
|
||||
Test_Purpose
|
||||
from
|
||||
staging2.IHTNST_NST_H1_block where trx_record=1;
|
||||
|
||||
update transactional.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_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from staging2.IHTNST_nst_footer_block b
|
||||
where a.file_sheet_mnemonic='IHTNST_NST' and trx_record=1;
|
||||
|
||||
insert into transactional.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tyre_type,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
tyre_ply_rating,
|
||||
tyre_load_carrying_capacity,
|
||||
tyre_wheel_rim_make_and_size
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
tyre_details,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
ply_rating::numeric ,
|
||||
load_carrying_capacity,
|
||||
wheel_rim_make_size
|
||||
from staging2.IHTNST_nst_tyre_details_block where trx_record=1;
|
||||
|
||||
|
||||
insert into transactional.test_instance_engine_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
low_idle_declared,
|
||||
low_idle_observed,
|
||||
high_idle_declared,
|
||||
high_idle_observed,
|
||||
rated_rpm,
|
||||
rated_rpm_observed,
|
||||
engine_to_pto_ratio_540_pto
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
low_idle_declared,
|
||||
low_idle_observed::numeric,
|
||||
high_idle_declared,
|
||||
high_idle_observed::numeric,
|
||||
rated_rpm_declared::numeric,
|
||||
rated_rpm_observed::numeric,
|
||||
engine_to_pto_ratio
|
||||
from staging2.IHTNST_nst_engine_rpm_block where trx_record=1;
|
||||
|
||||
insert into transactional.test_instance_tractor_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
weight_reactions_front_kg,
|
||||
tractor_weight_front_observed_kg,
|
||||
tractor_weight_front_remark,
|
||||
weight_reactions_rear_kg,
|
||||
tractor_weight_rear_observed_kg,
|
||||
tractor_weight_rear_remark,
|
||||
tractor_weight_total_kg,
|
||||
tractor_weight_total_observed_kg,
|
||||
tractor_weight_total_remark
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
front_weight_declared::numeric ,
|
||||
front_weight_observed::numeric,
|
||||
front_weight_remark,
|
||||
rear_weight_declared::numeric,
|
||||
rear_weight_observed::numeric,
|
||||
rear_weight_remark,
|
||||
total_weight_declared::numeric,
|
||||
total_weight_observed::numeric,
|
||||
total_weight_remark
|
||||
from staging2.IHTNST_nst_weight_block where trx_record=1;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set mahindra_model_yn = (
|
||||
case when tractor_make like 'Mahindra%' then 'Y' else 'N' end
|
||||
) where file_syspk =__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info a
|
||||
set test_tractor_yn ='Y' where syspk in
|
||||
(select min(syspk) from transactional.test_instance_tractor_info b
|
||||
where b.file_syspk =a.file_syspk)
|
||||
and a.file_syspk =__file_syspk;
|
||||
|
||||
|
||||
/*block */
|
||||
|
||||
insert into transactional.test_instance_atmospheric_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
ambient_temp_c,
|
||||
humidity_pct,
|
||||
pressure_kpa,
|
||||
background_noise_dba,
|
||||
wind_velocity_kmph
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
ambient_temp_c::numeric,
|
||||
humidity::numeric,
|
||||
pressure_kpa::numeric,
|
||||
background_noise::numeric,
|
||||
wind_velocity
|
||||
from staging2.IHTNST_nst_atmos_cond_block where trx_record=1;
|
||||
|
||||
insert into transactional.IHT_noise_measurement_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_type,
|
||||
test_mode,
|
||||
gear,
|
||||
noise_level_1_db_a,
|
||||
noise_level_2_db_a,
|
||||
noise_level_3_db_a
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column1,
|
||||
column2,
|
||||
column3,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric
|
||||
from staging2.IHTNST_nst_stand_noise_block where trx_record=1;
|
||||
|
||||
update transactional.IHT_noise_measurement_results
|
||||
set test_condition = (select column4
|
||||
from staging2.IHTNST_nst_stand_noise_block
|
||||
where block_row_number=3) where file_syspk = __file_syspk;
|
||||
|
||||
insert into transactional.IHT_noise_measurement_test
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_type,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_type,
|
||||
test_mode
|
||||
from transactional.IHT_noise_measurement_results where test_type='BY STANDER’S NOISE';
|
||||
|
||||
update transactional.IHT_noise_measurement_test
|
||||
set acceptance_criteria=b.acceptance_criteria,
|
||||
remarks =b.remarks
|
||||
from staging2.IHTNST_nst_stand_noise_block b
|
||||
where b.column1 ='BY STANDER’S NOISE' and test_type='BY STANDER’S NOISE' and trx_record=1;
|
||||
|
||||
insert into transactional.IHT_noise_measurement_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_type,
|
||||
test_mode,
|
||||
gear,
|
||||
noise_level_1_db_a,
|
||||
noise_level_2_db_a,
|
||||
noise_level_3_db_a
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column1,
|
||||
column2,
|
||||
column3,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9::numeric
|
||||
from staging2.IHTNST_nst_stand_noise_block where trx_record=1;
|
||||
|
||||
update transactional.IHT_noise_measurement_results
|
||||
set test_condition = (select column7
|
||||
from staging2.IHTNST_nst_stand_noise_block
|
||||
where block_row_number=3) where test_condition is null;
|
||||
|
||||
insert into transactional.IHT_noise_measurement_test
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_type,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_type,
|
||||
test_mode
|
||||
from transactional.IHT_noise_measurement_results where test_type='BY STANDER’S NOISE';
|
||||
|
||||
update transactional.IHT_noise_measurement_test
|
||||
set acceptance_criteria=b.acceptance_criteria,
|
||||
remarks =b.remarks
|
||||
from staging2.IHTNST_nst_stand_noise_block b
|
||||
where b.column1 ='BY STANDER’S NOISE' and test_type='BY STANDER’S NOISE' and trx_record=1;
|
||||
|
||||
insert into transactional.IHT_noise_measurement_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_type,
|
||||
test_mode,
|
||||
gear,
|
||||
load_kg,
|
||||
speed_kmph,
|
||||
speed_rpm,
|
||||
noise_level_1_db_a,
|
||||
noise_level_2_db_a,
|
||||
noise_level_3_db_a
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column1,
|
||||
column2,
|
||||
column3,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9::numeric
|
||||
from staging2.IHTNST_nst_oel_noise_block where trx_record=1;
|
||||
|
||||
update transactional.IHT_noise_measurement_test
|
||||
set acceptance_criteria=b.acceptance_criteria,
|
||||
remarks =b.remarks
|
||||
from staging2.IHTNST_nst_oel_noise_block b
|
||||
where b.column1 ='OEL Noise without Load' and test_type='OEL Noise without Load';
|
||||
|
||||
insert into transactional.IHT_noise_measurement_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_type,
|
||||
test_mode,
|
||||
gear,
|
||||
load_kg,
|
||||
speed_kmph,
|
||||
speed_rpm,
|
||||
noise_level_1_db_a,
|
||||
noise_level_2_db_a,
|
||||
noise_level_3_db_a
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column1,
|
||||
column2,
|
||||
column3,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9::numeric
|
||||
from staging2.IHTNST_nst_oel_noise_load_block where trx_record=1;
|
||||
|
||||
update transactional.IHT_noise_measurement_test
|
||||
set acceptance_criteria=b.acceptance_criteria,
|
||||
remarks =b.remarks
|
||||
from staging2.IHTNST_nst_oel_noise_load_block b
|
||||
where b.column1 ='OEL Noise with Load' and test_type='OEL Noise with Load';
|
||||
|
||||
insert into transactional.IHT_noise_measurement_test
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_type,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_type,
|
||||
test_mode
|
||||
from transactional.IHT_noise_measurement_results where test_type ='OEL Noise without Load' ;
|
||||
|
||||
insert into transactional.IHT_noise_measurement_test
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_type,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_type,
|
||||
test_mode
|
||||
from transactional.IHT_noise_measurement_results where test_type ='OEL Noise with Load';
|
||||
|
||||
delete from transactional.IHT_noise_measurement_test a
|
||||
using transactional.IHT_noise_measurement_test b
|
||||
where (a.syspk < b.syspk and
|
||||
a.test_condition is not null and
|
||||
a.test_condition =b.test_condition and
|
||||
a.test_mode =b.test_mode and a.test_type=b.test_type) or
|
||||
(a.syspk < b.syspk and a.test_condition is null and a.test_mode =b.test_mode and a.test_type=b.test_type);
|
||||
|
||||
update transactional.IHT_noise_measurement_results a
|
||||
set noise_measurement_id =(select syspk
|
||||
from transactional.IHT_noise_measurement_test b
|
||||
where (a.test_condition =b.test_condition and a.test_condition is not null and
|
||||
a.test_mode =b.test_mode and a.test_type=b.test_type) or
|
||||
(a.test_condition is null and a.test_mode =b.test_mode and a.test_type=b.test_type));
|
||||
|
||||
|
||||
select syspk into __test_instance_id from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_model into __model from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_make into __make from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select syspk from transactional.test_master into __test_master_id where test_type ='In House';
|
||||
select syspk into __test_instance_tractor_id from transactional.test_instance_tractor_info where file_syspk =__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance
|
||||
set test_master_id =__test_master_id,
|
||||
test_tractor_id =__test_instance_tractor_id
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_engine_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_atmospheric_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.IHT_noise_measurement_results
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.IHT_noise_measurement_test
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'trx', 'fn_IHTNST_NST_TRX', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
917
onetime/dataloadfunctions/IHT/IHT_NST_STG2.sql
Executable file
917
onetime/dataloadfunctions/IHT/IHT_NST_STG2.sql
Executable file
@@ -0,0 +1,917 @@
|
||||
drop function if exists staging2.fn_IHTNST_NST_block;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTNST_NST_block(p_client_id int,p_function_id int, p_file_mnemonic text,p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare err_query int;
|
||||
declare err_block text;
|
||||
|
||||
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTNST_NST_block
|
||||
Function Desc: This function populates data into staging 2 block
|
||||
File Format: IHTNST
|
||||
Sheet Format: IHTNST_NST
|
||||
Creation Date: March 25 2021
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTNST_NST_block(p_client_id,p_function_id, p_file_mnemonic,
|
||||
p_file_sheet_mnemonic, p_file_syspk)
|
||||
Function call ex: select staging2.fn_IHTNST_NST_block(1,2,'IHTNST','IHTNST_NST',456)
|
||||
***************************************************************/
|
||||
|
||||
|
||||
SET search_path TO staging2;
|
||||
|
||||
/* to process multiple files - re-runnability*/
|
||||
|
||||
truncate table staging2.IHTNST_NST_H1_Int;
|
||||
truncate table staging2.IHTNST_NST_H1_block;
|
||||
truncate table staging2.IHTNST_NST_Tyre_Details_Block;
|
||||
truncate table staging2.IHTNST_NST_Engine_RPM_Atmos_Int;
|
||||
truncate table staging2.IHTNST_NST_Engine_RPM_Block;
|
||||
truncate table staging2.IHTNST_NST_Weight_Block;
|
||||
truncate table staging2.IHTNST_NST_Atmos_Cond_Block;
|
||||
truncate table staging2.IHTNST_NST_STAND_Noise_Block;
|
||||
truncate table staging2.IHTNST_NST_OEL_Noise_Block;
|
||||
truncate table staging2.IHTNST_NST_OEL_Noise_Load_Block;
|
||||
truncate table staging2.IHTNST_NST_Footer_Block;
|
||||
truncate table staging2.stg_specific_table_IHTNST_NST;
|
||||
truncate table staging2.stg_process_table_IHTNST_NST;
|
||||
|
||||
|
||||
execute 'delete from fw_core.fw_jobctl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=null,
|
||||
row_previous_number=null,
|
||||
row_read_end=null,
|
||||
run_time=null
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* transfer data from generic to specific for IHTNST */
|
||||
execute 'insert into staging2.stg_specific_table_IHTNST_NST
|
||||
select * from staging1.staging_generic_table a
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''
|
||||
and a.file_syspk='||p_file_syspk||'';
|
||||
|
||||
select count(*) into err_query from staging2.stg_specific_table_IHTNST_NST;
|
||||
|
||||
|
||||
if err_query=0 then
|
||||
err_context := 'data not present';
|
||||
raise exception using
|
||||
message = 'No Data for IHT NST',
|
||||
detail = 'No data in table stg_specific_table_IHTNST_NST',
|
||||
errcode = '42704',
|
||||
hint = 'check sheet mnemonic in generic table, if it is null update it';
|
||||
end if;
|
||||
|
||||
/* trimming data */
|
||||
update staging2.stg_specific_table_IHTNST_NST set column8='Objective' where lower(column8) like 'objective%';
|
||||
|
||||
update staging2.stg_specific_table_IHTNST_NST set column8='Condition' where lower(column8) like 'condition%';
|
||||
|
||||
update staging2.stg_specific_table_IHTNST_NST set column3='Remarks' where lower(column3) like 'remarks%';
|
||||
|
||||
update staging2.stg_specific_table_IHTNST_NST set column7='Acceptance Criteria'
|
||||
where lower(column7) like 'acceptance criteria%';
|
||||
|
||||
|
||||
update transactional.source_config set F1_source=F1_modified ;
|
||||
|
||||
|
||||
/* keyword match in config table*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=(select min(b.row_number)
|
||||
from staging2.stg_specific_table_IHTNST_NST b
|
||||
where upper(F1_modified)=upper(column3)
|
||||
and b.is_rownumber_fetched is null)
|
||||
where a.row_number_start is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* reverese update in process table for match*/
|
||||
execute 'update staging2.stg_specific_table_IHTNST_NST a
|
||||
set is_rownumber_fetched=1
|
||||
from transactional.source_config b
|
||||
where upper(F1_modified)=upper(column3)
|
||||
and b.row_number_start=a.row_number
|
||||
and is_rownumber_fetched is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'update transactional.source_config a set row_previous_number=row_number_start-1
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* update config files for row numbers start, end */
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end= (select b.row_number_start
|
||||
from transactional.source_config b
|
||||
where b.syspk=a.syspk+1 and file_mnemonic='''||p_file_mnemonic||''' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||''' )
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* config file last field update as null otherwise it picks up next format row number*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end = null ,run_time=current_timestamp
|
||||
where f1_modified =''Prepared by''
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* tagging block_row_numbers*/
|
||||
execute 'insert into staging2.stg_process_table_IHTNST_NST
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTNST_NST a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Test Request No''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTNST_NST
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTNST_NST a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Tyre Details''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTNST_NST
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTNST_NST a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Engine RPM''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTNST_NST
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTNST_NST a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''BY STANDER’S NOISE''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTNST_NST
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTNST_NST a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''OEL Noise without Load''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTNST_NST
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTNST_NST a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''OEL Noise with Load''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTNST_NST
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTNST_NST a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Prepared by''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/*selecting tractor model*/
|
||||
select column4 into __model from staging2.stg_process_table_IHTNST_nst a
|
||||
where block_tag='IHTNST_NST_H1' and trim(column3)='Tractor Model';
|
||||
|
||||
/*block starts - IHTNST_NST_H1_BLOCK */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTNST_NST_H1_BLOCK',__file_mnemonic,__file_sheet_mnemonic,1);
|
||||
err_block:='IHTNST_NST_H1_BLOCK';
|
||||
insert into staging2.IHTNST_NST_H1_INT (c1,c2)
|
||||
select a.column3,column4 from staging2.stg_process_table_IHTNST_NST a where block_tag='IHTNST_NST_H1';
|
||||
|
||||
insert into staging2.IHTNST_NST_H1_INT (c1,c2)
|
||||
select a.column6,column7 from staging2.stg_process_table_IHTNST_NST a where block_tag='IHTNST_NST_H1';
|
||||
|
||||
insert into staging2.IHTNST_NST_H1_INT (c1,c2)
|
||||
select 'Objective',column8
|
||||
from staging2.stg_process_table_IHTNST_NST a
|
||||
where block_tag='IHTNST_NST_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTNST_NST a
|
||||
where column8='Objective'
|
||||
and block_tag='IHTNST_NST_H1'
|
||||
);
|
||||
|
||||
insert into staging2.IHTNST_NST_H1_INT (c1,c2)
|
||||
select 'Condition',column8
|
||||
from staging2.stg_process_table_IHTNST_NST a
|
||||
where block_tag='IHTNST_NST_Tyre_Details'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTNST_NST a
|
||||
where column8='Condition'
|
||||
and block_tag='IHTNST_NST_Tyre_Details'
|
||||
);
|
||||
|
||||
insert into staging2.IHTNST_NST_H1_INT (c1,c2)
|
||||
select 'Test Purpose',column6
|
||||
from staging2.stg_process_table_IHTNST_NST a
|
||||
where column3='Test Purpose' and block_tag ='IHTNST_NST_Engine_RPM_Atmos';
|
||||
|
||||
|
||||
update staging2.IHTNST_NST_H1_Int set model=__model;
|
||||
execute 'update staging2.IHTNST_NST_H1_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
insert into staging2.IHTNST_NST_H1_Block
|
||||
(
|
||||
dummy_f,
|
||||
Test_Request_no,
|
||||
Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Tractor_Model,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date,
|
||||
No_of_Sample,
|
||||
Test_Start_Date,
|
||||
Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Facility,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Test_standard_refer,
|
||||
Objective,
|
||||
condition,
|
||||
Test_Purpose
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{c2}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[c2::text]) AS val
|
||||
FROM staging2.IHTNST_NST_H1_INT
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,
|
||||
a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,a_18 text,a_19 text);
|
||||
|
||||
|
||||
delete from staging2.IHTNST_NST_H1_Block where dummy_f is null ;
|
||||
update staging2.IHTNST_NST_H1_Block set model=__model;
|
||||
execute 'update staging2.IHTNST_NST_H1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTNST_NST_H1_BLOCK');
|
||||
|
||||
/*block starts - IHTNST_NST_Tyre_Details_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTNST_NST_Tyre_Details_Block',__file_mnemonic,__file_sheet_mnemonic,2);
|
||||
err_block:='IHTNST_NST_Tyre_Details_Block';
|
||||
|
||||
insert into staging2.IHTNST_NST_Tyre_Details_Block
|
||||
(
|
||||
dummy_f,
|
||||
Tyre_Details,
|
||||
Tyre_Make,
|
||||
Tyre_size,
|
||||
Ply_Rating,
|
||||
Load_Carrying_Capacity,
|
||||
Wheel_rim_Make_size
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column4,column6}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column4::text,column6::text]) AS val
|
||||
FROM staging2.stg_process_table_IHTNST_NST where block_tag=''IHTNST_NST_Tyre_Details''
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text);
|
||||
|
||||
update staging2.IHTNST_NST_Tyre_Details_Block
|
||||
set ply_rating =replace(ply_rating,' Ply','');
|
||||
|
||||
delete from staging2.IHTNST_NST_Tyre_Details_Block where dummy_f is null ;
|
||||
update staging2.IHTNST_NST_Tyre_Details_Block set model=__model;
|
||||
execute 'update staging2.IHTNST_NST_Tyre_Details_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTNST_NST_Tyre_Details_Block');
|
||||
|
||||
|
||||
/* inserting Engine_RPM_Atmos_INT */
|
||||
|
||||
insert into staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
(
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,block_row_number
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,block_row_number
|
||||
from staging2.stg_process_table_IHTNST_NST a
|
||||
where block_tag='IHTNST_NST_Engine_RPM_Atmos'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
set column8=(select column6 from staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=9) where block_row_number=5;
|
||||
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
set column6 = null where block_row_number=9;
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
set column9=(select column7 from staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=9) where block_row_number=5;
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
set column7=null where block_row_number=9;
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
set column8=(select column8 from staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=9)where block_row_number=6;
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
set column8 =null where block_row_number=9;
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
set column9=(select column9 from staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=9)where block_row_number=6;
|
||||
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
set column9 =null where block_row_number=9;
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Atmos_Int set model=__model;
|
||||
execute 'update staging2.IHTNST_NST_Engine_RPM_Atmos_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/*block starts - IHTNST_NST_Engine_RPM_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTNST_NST_Engine_RPM_Block',__file_mnemonic,__file_sheet_mnemonic,3);
|
||||
err_block:='IHTNST_NST_Engine_RPM_Block';
|
||||
insert into staging2.IHTNST_NST_Engine_RPM_Block(dummy_f) values ('dummy');
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Block
|
||||
set low_idle_declared=(select column4 from
|
||||
staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=2 and column3='Low Idle RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Block
|
||||
set low_idle_observed=(select column6 from
|
||||
staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=2 and column3='Low Idle RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Block
|
||||
set high_idle_declared=(select column4 from
|
||||
staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=3 and column3='High IdleRPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Block
|
||||
set high_idle_observed=(select column6 from
|
||||
staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=3 and column3='High IdleRPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Block
|
||||
set rated_rpm_declared=(select column4 from
|
||||
staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=4 and column3='Rated RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Block
|
||||
set rated_rpm_observed=(select column6 from
|
||||
staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=4 and column3='Rated RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Block
|
||||
set Engine_to_PTO_Ratio=(select column4 from
|
||||
staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=9 and column3='Engine to PTO Ratio')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Block
|
||||
set low_idle_remark= (select column7
|
||||
FROM staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=2 and column3='Low Idle RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Block
|
||||
set high_idle_remark= (select column7
|
||||
FROM staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=3 and column3='High IdleRPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update staging2.IHTNST_NST_Engine_RPM_Block set model=__model;
|
||||
execute 'update staging2.IHTNST_NST_Engine_RPM_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTNST_NST_Engine_RPM_Block');
|
||||
|
||||
/*block starts -IHTNST_NST_Weight_Block*/
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTNST_NST_Weight_Block',__file_mnemonic,__file_sheet_mnemonic,4);
|
||||
err_block:='IHTNST_NST_Weight_Block';
|
||||
insert into staging2.IHTNST_NST_Weight_Block(dummy_f) values ('dummy');
|
||||
|
||||
update staging2.IHTNST_NST_Weight_Block
|
||||
set Front_weight_declared=(select column4 from
|
||||
staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=6 and column3='Front')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Weight_Block
|
||||
set Front_weight_observed=(select column6 from
|
||||
staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=6 and column3='Front')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Weight_Block
|
||||
set Rear_weight_declared=(select column4 from
|
||||
staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=7 and column3='Rear')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Weight_Block
|
||||
set Rear_weight_observed=(select column6 from
|
||||
staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=7 and column3='Rear')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Weight_Block
|
||||
set Total_weight_declared=(select column4 from
|
||||
staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=8 and column3='Total')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Weight_Block
|
||||
set Total_weight_observed=(select column6 from
|
||||
staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=8 and column3='Total')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Weight_Block
|
||||
set front_weight_remark= (select column7
|
||||
FROM staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=6 and column3='Front')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Weight_Block
|
||||
set rear_weight_remark= (select column7
|
||||
FROM staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=7 and column3='Rear')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Weight_Block
|
||||
set total_weight_remark= (select column7
|
||||
FROM staging2.IHTNST_NST_Engine_RPM_Atmos_Int
|
||||
where block_row_number=8 and column3='Total')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update staging2.IHTNST_NST_Weight_Block set model=__model;
|
||||
execute 'update staging2.IHTNST_NST_Weight_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTNST_NST_Weight_Block');
|
||||
|
||||
|
||||
/*block starts - IHTNST_NST_Atmos_Cond_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTNST_NST_Atmos_Cond_Block',__file_mnemonic,__file_sheet_mnemonic,5);
|
||||
err_block:='IHTNST_NST_Atmos_Cond_Block';
|
||||
insert into staging2.IHTNST_NST_Atmos_Cond_Block
|
||||
(
|
||||
dummy_f,
|
||||
Ambient_temp_C,
|
||||
humidity,
|
||||
Pressure_kPa,
|
||||
Background_Noise,
|
||||
wind_velocity
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column9}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column9::text]) AS val
|
||||
FROM staging2.IHTNST_NST_Engine_RPM_Atmos_Int where block_row_number between 2 and 6
|
||||
ORDER BY generate_series(1,15),block_row_number,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text);
|
||||
|
||||
delete from staging2.IHTNST_NST_Atmos_Cond_Block where dummy_f is null ;
|
||||
update staging2.IHTNST_NST_Atmos_Cond_Block set model=__model;
|
||||
execute 'update staging2.IHTNST_NST_Atmos_Cond_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTNST_NST_Atmos_Cond_Block');
|
||||
|
||||
|
||||
/*block starts - IHTNST_NST_STAND_Noise_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTNST_NST_STAND_Noise_Block',__file_mnemonic,__file_sheet_mnemonic,6);
|
||||
err_block:='IHTNST_NST_STAND_Noise_Block';
|
||||
insert into staging2.IHTNST_NST_STAND_Noise_Block
|
||||
(
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,block_row_number
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,block_row_number
|
||||
from staging2.stg_process_table_IHTNST_NST a
|
||||
where block_tag='IHTNST_NST_STAND_Noise'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTNST_NST_STAND_Noise_Block
|
||||
set column2=column3 where column4 is null and block_row_number in (2,6);
|
||||
|
||||
update staging2.IHTNST_NST_STAND_Noise_Block
|
||||
set column1=column3 where column4 is null and block_row_number =1;
|
||||
|
||||
update staging2.IHTNST_NST_STAND_Noise_Block a
|
||||
set column1= b.first_value from (SELECT
|
||||
block_row_number, column1, value_partition, first_value(column1) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column1,
|
||||
sum(case when column1 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTNST_NST_STAND_Noise_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number = b.block_row_number;
|
||||
|
||||
update staging2.IHTNST_NST_STAND_Noise_Block a
|
||||
set column2= b.first_value from (SELECT
|
||||
block_row_number, column2, value_partition, first_value(column2) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column2,
|
||||
sum(case when column2 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTNST_NST_STAND_Noise_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number = b.block_row_number;
|
||||
|
||||
update staging2.IHTNST_NST_STAND_Noise_Block
|
||||
set trx_record=0 where block_row_number <>5;
|
||||
|
||||
update staging2.IHTNST_NST_STAND_Noise_Block
|
||||
set remarks=(select column3
|
||||
from staging2.stg_process_table_IHTNST_NST a
|
||||
where block_tag='IHTNST_NST_STAND_Noise' and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTNST_NST a
|
||||
where lower(column3)='remarks'
|
||||
and block_tag='IHTNST_NST_STAND_Noise'
|
||||
));
|
||||
|
||||
update staging2.IHTNST_NST_STAND_Noise_Block
|
||||
set acceptance_criteria=(select column7
|
||||
from staging2.stg_process_table_IHTNST_NST a
|
||||
where block_tag='IHTNST_NST_STAND_Noise' and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTNST_NST a
|
||||
where lower(column7)='acceptance criteria'
|
||||
and block_tag='IHTNST_NST_STAND_Noise'
|
||||
));
|
||||
|
||||
update staging2.IHTNST_NST_STAND_Noise_Block set model=__model;
|
||||
execute 'update staging2.IHTNST_NST_STAND_Noise_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTNST_NST_STAND_Noise_Block');
|
||||
|
||||
|
||||
/*block starts - IHTNST_NST_OEL_Noise_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTNST_NST_OEL_Noise_Block',__file_mnemonic,__file_sheet_mnemonic,7);
|
||||
err_block:='IHTNST_NST_OEL_Noise_Block';
|
||||
insert into staging2.IHTNST_NST_OEL_Noise_Block
|
||||
(
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,block_row_number
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,block_row_number
|
||||
from staging2.stg_process_table_IHTNST_NST a
|
||||
where block_tag='IHTNST_NST_OEL_Noise'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Block
|
||||
set column2=column3 where column4 is null and block_row_number in (2,8,14);
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Block
|
||||
set column1=column3 where column4 is null and block_row_number =1;
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Block a
|
||||
set column1= b.first_value from (SELECT
|
||||
block_row_number, column1, value_partition, first_value(column1) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column1,
|
||||
sum(case when column1 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTNST_NST_OEL_Noise_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number = b.block_row_number;
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Block a
|
||||
set column2= b.first_value from (SELECT
|
||||
block_row_number, column2, value_partition, first_value(column2) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column2,
|
||||
sum(case when column2 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTNST_NST_OEL_Noise_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number = b.block_row_number;
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Block
|
||||
set trx_record=0 where block_row_number in (1,2,3,4,8,9,10,14,15,16,17,18);
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Block
|
||||
set remarks=(select column3
|
||||
from staging2.stg_process_table_IHTNST_NST a
|
||||
where block_tag='IHTNST_NST_OEL_Noise' and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTNST_NST a
|
||||
where lower(column3)='remarks'
|
||||
and block_tag='IHTNST_NST_OEL_Noise'
|
||||
));
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Block
|
||||
set acceptance_criteria=(select column7
|
||||
from staging2.stg_process_table_IHTNST_NST a
|
||||
where block_tag='IHTNST_NST_OEL_Noise' and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTNST_NST a
|
||||
where lower(column7)='acceptance criteria'
|
||||
and block_tag='IHTNST_NST_OEL_Noise'
|
||||
));
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Block set model=__model;
|
||||
execute 'update staging2.IHTNST_NST_OEL_Noise_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTNST_NST_OEL_Noise_Block');
|
||||
|
||||
/*block starts - IHTNST_NST_OEL_Noise_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTNST_NST_OEL_Noise_Load_Block',__file_mnemonic,__file_sheet_mnemonic,8);
|
||||
err_block:='IHTNST_NST_OEL_Noise_Load_Block';
|
||||
insert into staging2.IHTNST_NST_OEL_Noise_Load_Block
|
||||
(
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,block_row_number
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,block_row_number
|
||||
from staging2.stg_process_table_IHTNST_NST a
|
||||
where block_tag='IHTNST_NST_OEL_Noise_Load'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Load_Block
|
||||
set column2=column3 where column4 is null and block_row_number in (2,5,11);
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Load_Block
|
||||
set column1=column3 where column4 is null and block_row_number =1;
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Load_Block a
|
||||
set column1= b.first_value from (SELECT
|
||||
block_row_number, column1, value_partition, first_value(column1) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column1,
|
||||
sum(case when column1 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTNST_NST_OEL_Noise_Load_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number = b.block_row_number;
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Load_Block a
|
||||
set column2= b.first_value from (SELECT
|
||||
block_row_number, column2, value_partition, first_value(column2) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column2,
|
||||
sum(case when column2 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTNST_NST_OEL_Noise_Load_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number = b.block_row_number;
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Load_Block
|
||||
set trx_record=0 where block_row_number not in (8,9,10,14,15,16);
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Load_Block
|
||||
set remarks=(select column3
|
||||
from staging2.stg_process_table_IHTNST_NST a
|
||||
where block_tag='IHTNST_NST_OEL_Noise_Load' and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTNST_NST a
|
||||
where lower(column3)='remarks'
|
||||
and block_tag='IHTNST_NST_OEL_Noise_Load'
|
||||
));
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Load_Block
|
||||
set acceptance_criteria=(select column7
|
||||
from staging2.stg_process_table_IHTNST_NST a
|
||||
where block_tag='IHTNST_NST_OEL_Noise_Load' and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTNST_NST a
|
||||
where lower(column7)='acceptance criteria'
|
||||
and block_tag='IHTNST_NST_OEL_Noise_Load'
|
||||
));
|
||||
|
||||
update staging2.IHTNST_NST_OEL_Noise_Load_Block set model=__model;
|
||||
execute 'update staging2.IHTNST_NST_OEL_Noise_Load_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTNST_NST_OEL_Noise_Load_Block');
|
||||
|
||||
|
||||
|
||||
/*block starts - IHTNST_NST_Footer_block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTNST_NST_Footer_block',__file_mnemonic,__file_sheet_mnemonic,9);
|
||||
err_block:='IHTNST_NST_Footer_block';
|
||||
|
||||
insert into staging2.IHTNST_NST_Footer_block(dummy_f) values ('dummy');
|
||||
|
||||
update staging2.IHTNST_NST_Footer_block a
|
||||
set prepared_by=( select column4 from staging2.stg_process_table_IHTNST_NST b
|
||||
where b.block_tag='IHTNST_NST_Footer'
|
||||
and lower(column3)='prepared by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Footer_block a
|
||||
set reviewed_by=( select column4 from staging2.stg_process_table_IHTNST_NST b
|
||||
where b.block_tag='IHTNST_NST_Footer'
|
||||
and lower(column3)='reviewed by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Footer_block a
|
||||
set approved_by=( select column4 from staging2.stg_process_table_IHTNST_NST b
|
||||
where b.block_tag='IHTNST_NST_Footer'
|
||||
and lower(column3)='approved by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Footer_block a
|
||||
set comments=( select column3 from staging2.stg_process_table_IHTNST_NST b
|
||||
where b.block_tag='IHTNST_NST_Footer'
|
||||
and block_row_number=5 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Footer_block a
|
||||
set rev1=( select column3 from staging2.stg_process_table_IHTNST_NST b
|
||||
where b.block_tag='IHTNST_NST_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
update staging2.IHTNST_NST_Footer_block a
|
||||
set rev2=( select column5 from staging2.stg_process_table_IHTNST_NST b
|
||||
where b.block_tag='IHTNST_NST_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Footer_block a
|
||||
set rev3=( select column8 from staging2.stg_process_table_IHTNST_NST b
|
||||
where b.block_tag='IHTNST_NST_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Footer_block a
|
||||
set replaces=( select column9 from staging2.stg_process_table_IHTNST_NST b
|
||||
where b.block_tag='IHTNST_NST_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Footer_block a
|
||||
set revision_no=( select column9 from staging2.stg_process_table_IHTNST_NST b
|
||||
where b.block_tag='IHTNST_NST_Footer'
|
||||
and block_row_number=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Footer_block a
|
||||
set prepared_date=( select column8 from staging2.stg_process_table_IHTNST_NST b
|
||||
where b.block_tag='IHTNST_NST_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Footer_block a
|
||||
set reviewed_date=( select column8 from staging2.stg_process_table_IHTNST_NST b
|
||||
where b.block_tag='IHTNST_NST_Footer'
|
||||
and block_row_number=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Footer_block a
|
||||
set approved_date=( select column8 from staging2.stg_process_table_IHTNST_NST b
|
||||
where b.block_tag='IHTNST_NST_Footer'
|
||||
and block_row_number=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTNST_NST_Footer_block set model=__model;
|
||||
execute 'update staging2.IHTNST_NST_Footer_block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTNST_NST_Footer_block');
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'stg2', 'fn_IHTNST_NST_block', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
379
onetime/dataloadfunctions/IHT/IHT_SLL_ODS.sql
Executable file
379
onetime/dataloadfunctions/IHT/IHT_SLL_ODS.sql
Executable file
@@ -0,0 +1,379 @@
|
||||
drop function if exists staging2.fn_IHTSLL_SLL_TRX;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTSLL_SLL_TRX(p_client_id int,p_function_id int, p_file_mnemonic text,
|
||||
p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __test_instance_id int;
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare _error int;
|
||||
declare __test_master_id int;
|
||||
declare __test_instance_tractor_id int;
|
||||
begin
|
||||
__file_syspk := p_file_syspk;
|
||||
/************************************************************
|
||||
Function Name:fn_IHTSLL_SLL_TRX
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHTSLL
|
||||
Sheet Format: IHTSLL_SLL
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTSLL_SLL_TRX()
|
||||
***************************************************************/
|
||||
insert into transactional.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
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,
|
||||
objective_of_test,
|
||||
acceptance_criteria,
|
||||
remarks,
|
||||
test_purpose
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
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,
|
||||
Remarks,
|
||||
Test_Purpose
|
||||
from staging2.IHTSLL_SLL_H1_block where trx_record=1;
|
||||
|
||||
update transactional.test_instance a
|
||||
set
|
||||
report_prepared_date=to_date(b.prepared_date,'DD-MM-YYYY'),
|
||||
report_reviewed_date=to_date(b.reviewed_date,'DD-MM-YYYY'),
|
||||
report_approved_date=to_date(b.approved_date,'DD-MM-YYYY'),
|
||||
report_prepared_by=b.prepared_by,
|
||||
report_reviewed_by=b.reviewed_by,
|
||||
report_approved_by=b.approved_by,
|
||||
report_template_replaces=b.replaces,
|
||||
report_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from staging2.IHTSLL_SLL_footer_block b
|
||||
where a.file_sheet_mnemonic ='IHTSLL_SLL' and trx_record=1;
|
||||
|
||||
insert into transactional.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tyre_type,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
tyre_ply_rating,
|
||||
tyre_load_carrying_capacity,
|
||||
tyre_pressure_kg_per_cm2,
|
||||
tyre_static_rolling_radius_mm,
|
||||
tyre_dynamic_rolling_radius_mm,
|
||||
tyre_wheel_rim_make_and_size
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
tyre_details,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
ply_rating::numeric,
|
||||
load_carrying_capacity,
|
||||
Pressure_kg_cm2::numeric ,
|
||||
Dynamic_rolling_radius::numeric ,
|
||||
Static_rolling_radius::numeric ,
|
||||
wheel_rim_make_size
|
||||
from staging2.IHTSLL_SLL_tyre_details_block where trx_record=1;
|
||||
|
||||
insert into transactional.test_instance_tractor_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
wheel_base_mm,
|
||||
rear_track_width_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
wheel_base::numeric ,
|
||||
rear_track_width::numeric
|
||||
from staging2.IHTSLL_SLL_wheel_block where trx_record=1;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set mahindra_model_yn = (
|
||||
case when lower(tractor_make) like 'mahindra%' then 'Y' else 'N' end
|
||||
) where file_syspk =__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info a
|
||||
set test_tractor_yn ='Y' where syspk in
|
||||
(select min(syspk) from transactional.test_instance_tractor_info b
|
||||
where b.file_syspk =a.file_syspk)
|
||||
and a.file_syspk =__file_syspk;
|
||||
|
||||
|
||||
/*block */
|
||||
|
||||
insert into transactional.test_instance_weight_reaction
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
total_weight_kg,
|
||||
front_reaction_kg,
|
||||
rear_reaction_kg,
|
||||
left_reaction_fl_rl_kg,
|
||||
right_reaction_fr_rr_kg,
|
||||
front_left_reaction_kg,
|
||||
front_right_reactionkg,
|
||||
rear_left_reaction_kg,
|
||||
rear_right_reactionkg,
|
||||
distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg::numeric,
|
||||
Front_Reaction_kg::numeric ,
|
||||
Rear_Reaction_kg::numeric ,
|
||||
Left_Reaction_FL_RL_kg::numeric ,
|
||||
Right_reaction_FR_RR_kg::numeric ,
|
||||
Front_Left_Reaction_kg::numeric ,
|
||||
Front_Right_Reaction_kg::numeric ,
|
||||
Rear_Left_Reaction_kg::numeric ,
|
||||
Rear_Right_Reaction_kg::numeric ,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1::numeric
|
||||
from staging2.IHTSLL_SLL_weight_block where trx_record=1;
|
||||
|
||||
|
||||
insert into transactional.IHT_gear_max_speed
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
gear,
|
||||
low_1000_rpm,
|
||||
rated_2300_rpm,
|
||||
specification,
|
||||
high_2500_rpm,
|
||||
actual_speed_pct,
|
||||
diff_in_speed_kmph
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3,
|
||||
column4::numeric ,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9::numeric
|
||||
from staging2.IHTSLL_sll_forward_block where trx_record=1;
|
||||
|
||||
insert into transactional.IHT_gear_max_speed
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
gear,
|
||||
low_1000_rpm,
|
||||
rated_2300_rpm,
|
||||
specification,
|
||||
high_2500_rpm,
|
||||
actual_speed_pct,
|
||||
diff_in_speed_kmph
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3,
|
||||
column4::numeric ,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9::numeric
|
||||
from staging2.IHTSLL_sll_reverse_block where trx_record=1;
|
||||
|
||||
insert into transactional.IHT_speed_lead_lag_measurement
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
gear,
|
||||
engine_rpm,
|
||||
wheel_drive_type,
|
||||
no_of_revolution_front,
|
||||
ratio,
|
||||
lead_lag_pct
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_mnemonic,
|
||||
file_sheet_mnemonic,
|
||||
make,model,
|
||||
column3,
|
||||
column4::numeric ,
|
||||
column5,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8
|
||||
from staging2.IHTSLL_sll_lead_lag_block where trx_record=1;
|
||||
|
||||
|
||||
select syspk into __test_instance_id from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_model into __model from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select tractor_make into __make from transactional.test_instance where file_syspk =__file_syspk;
|
||||
select syspk from transactional.test_master into __test_master_id where test_type ='In House';
|
||||
select syspk into __test_instance_tractor_id from transactional.test_instance_tractor_info where file_syspk =__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance
|
||||
set test_master_id =__test_master_id,
|
||||
test_tractor_id =__test_instance_tractor_id
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
|
||||
update transactional.test_instance_weight_reaction
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.IHT_gear_max_speed
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
update transactional.IHT_speed_lead_lag_measurement
|
||||
set test_instance_id=__test_instance_id,
|
||||
test_instance_tractor_id = __test_instance_tractor_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where file_syspk=__file_syspk;
|
||||
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'trx', 'fn_IHTSLL_SLL_TRX', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
670
onetime/dataloadfunctions/IHT/IHT_SLL_STG2.sql
Executable file
670
onetime/dataloadfunctions/IHT/IHT_SLL_STG2.sql
Executable file
@@ -0,0 +1,670 @@
|
||||
drop function if exists staging2.fn_IHTSLL_SLL_block;
|
||||
CREATE OR REPLACE FUNCTION staging2.fn_IHTSLL_SLL_block(p_client_id int,p_function_id int, p_file_mnemonic text,p_file_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_mnemonic text :=p_file_mnemonic;
|
||||
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare err_state text;
|
||||
declare err_msg text;
|
||||
declare err_detail text;
|
||||
declare err_hint text;
|
||||
declare err_context text;
|
||||
declare err_query int;
|
||||
declare err_block text;
|
||||
|
||||
begin
|
||||
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHTSLL_SLL_block
|
||||
Function Desc: This function populates data into staging 2 block
|
||||
File Format: IHTSLL
|
||||
Sheet Format: IHTSLL_SLL
|
||||
Creation Date: March 25 2021
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select staging2.fn_IHTSLL_SLL_block(p_client_id,p_function_id, p_file_mnemonic,
|
||||
p_file_sheet_mnemonic, p_file_syspk)
|
||||
Function call ex: select staging2.fn_IHTSLL_SLL_block(1,2,'IHTSLL','IHTSLL_SLL',456)
|
||||
***************************************************************/
|
||||
|
||||
|
||||
SET search_path TO staging2;
|
||||
|
||||
/* to process multiple files - re-runnability*/
|
||||
|
||||
truncate table staging2.IHTSLL_SLL_H1_Int;
|
||||
truncate table staging2.IHTSLL_SLL_H1_block;
|
||||
truncate table staging2.IHTSLL_SLL_Weight_Tyre_Int;
|
||||
truncate table staging2.IHTSLL_SLL_Weight_Block;
|
||||
truncate table staging2.IHTSLL_SLL_Wheel_Block;
|
||||
truncate table staging2.IHTSLL_SLL_Tyre_Details_Block;
|
||||
truncate table staging2.IHTSLL_SLL_Forward_Block;
|
||||
truncate table staging2.IHTSLL_SLL_Reverse_Block;
|
||||
truncate table staging2.IHTSLL_SLL_Lead_Lag_Block;
|
||||
truncate table staging2.IHTSLL_SLL_Footer_Block;
|
||||
truncate table staging2.stg_specific_table_IHTSLL_SLL;
|
||||
truncate table staging2.stg_process_table_IHTSLL_SLL;
|
||||
|
||||
|
||||
execute 'delete from fw_core.fw_jobctl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=null,
|
||||
row_previous_number=null,
|
||||
row_read_end=null,
|
||||
run_time=null
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* transfer data from generic to specific for IHTSLL */
|
||||
execute 'insert into staging2.stg_specific_table_IHTSLL_SLL
|
||||
select * from staging1.staging_generic_table a
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''
|
||||
and a.file_syspk='||p_file_syspk||'';
|
||||
|
||||
select count(*) into err_query from staging2.stg_specific_table_IHTSLL_SLL;
|
||||
|
||||
if err_query=0 then
|
||||
err_context := 'data not present';
|
||||
raise exception using
|
||||
message = 'No Data for IHTSLL',
|
||||
detail = 'No data in table stg_specific_table_IHTSLL_SLL',
|
||||
errcode = '42704',
|
||||
hint = 'check sheet mnemonic in generic table, if it is null update it';
|
||||
end if;
|
||||
|
||||
/* trimming data */
|
||||
update staging2.stg_specific_table_IHTSLL_SLL
|
||||
set column15='Objective' where lower(column15) like 'objective%';
|
||||
|
||||
update staging2.stg_specific_table_IHTSLL_SLL
|
||||
set column15='Acceptance criteria' where lower(column15) like 'acceptance criteria%';
|
||||
|
||||
update transactional.source_config set F1_source=F1_modified;
|
||||
|
||||
/* keyword match in config table*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_number_start=(select min(b.row_number)
|
||||
from staging2.stg_specific_table_IHTSLL_SLL b
|
||||
where upper(F1_modified)=upper(column3)
|
||||
and b.is_rownumber_fetched is null)
|
||||
where a.row_number_start is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* reverese update in process table for match*/
|
||||
execute 'update staging2.stg_specific_table_IHTSLL_SLL a
|
||||
set is_rownumber_fetched=1
|
||||
from transactional.source_config b
|
||||
where upper(F1_modified)=upper(column3)
|
||||
and b.row_number_start=a.row_number
|
||||
and is_rownumber_fetched is null
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'update transactional.source_config a set row_previous_number=row_number_start-1
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* update config files for row numbers start, end */
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end= (select b.row_number_start
|
||||
from transactional.source_config b
|
||||
where b.syspk=a.syspk+1 and file_mnemonic='''||p_file_mnemonic||''' and file_sheet_mnemonic='''||p_file_sheet_mnemonic||''' )
|
||||
where a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* config file last field update as null otherwise it picks up next format row number*/
|
||||
execute 'update transactional.source_config a
|
||||
set row_read_end = null ,run_time=current_timestamp
|
||||
where f1_modified =''Remarks:''
|
||||
and a.file_mnemonic='''||p_file_mnemonic||''' and a.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/* tagging block_row_numbers*/
|
||||
execute 'insert into staging2.stg_process_table_IHTSLL_SLL
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTSLL_SLL a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Test Request No''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTSLL_SLL
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTSLL_SLL a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Weight Reaction''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTSLL_SLL
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTSLL_SLL a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''K2-4WD HST EACH GEAR MAX SPEED - FORWARD''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTSLL_SLL
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTSLL_SLL a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''K2- 4WD HST EACH GEAR MAX SPEED REVERSE''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTSLL_SLL
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTSLL_SLL a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Lead / Lag Measurement on K2 4WD HST''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'insert into staging2.stg_process_table_IHTSLL_SLL
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
|
||||
from staging2.stg_specific_table_IHTSLL_SLL a
|
||||
join transactional.source_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Prepared by''
|
||||
and b.file_mnemonic='''||p_file_mnemonic||''' and b.file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
/*selecting tractor model*/
|
||||
select column6 into __model from staging2.stg_process_table_IHTSLL_SLL a
|
||||
where block_tag='IHTSLL_SLL_H1' and trim(column3)='Tractor Model';
|
||||
|
||||
/*block starts - IHTSLL_SLL_H1_BLOCK */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTSLL_SLL_H1_BLOCK',__file_mnemonic,__file_sheet_mnemonic,1);
|
||||
err_block:='IHTSLL_SLL_H1_BLOCK';
|
||||
|
||||
insert into staging2.IHTSLL_SLL_H1_INT (c1,c2)
|
||||
select a.column3,column6 from staging2.stg_process_table_IHTSLL_SLL a where block_tag='IHTSLL_SLL_H1';
|
||||
|
||||
insert into staging2.IHTSLL_SLL_H1_INT (c1,c2)
|
||||
select a.column9,column12 from staging2.stg_process_table_IHTSLL_SLL a where block_tag='IHTSLL_SLL_H1';
|
||||
|
||||
insert into staging2.IHTSLL_SLL_H1_INT (c1,c2)
|
||||
select 'Objective',column15
|
||||
from staging2.stg_process_table_IHTSLL_SLL a
|
||||
where block_tag='IHTSLL_SLL_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTSLL_SLL a
|
||||
where column15='Objective'
|
||||
and block_tag='IHTSLL_SLL_H1'
|
||||
);
|
||||
|
||||
insert into staging2.IHTSLL_SLL_H1_INT (c1,c2)
|
||||
select 'Acceptance criteria',column15
|
||||
from staging2.stg_process_table_IHTSLL_SLL a
|
||||
where block_tag='IHTSLL_SLL_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTSLL_SLL a
|
||||
where column15='Acceptance criteria'
|
||||
and block_tag='IHTSLL_SLL_H1'
|
||||
);
|
||||
|
||||
insert into staging2.IHTSLL_SLL_H1_INT (c1,c2)
|
||||
select split_part(column3,':',1),split_part(column3,':',2)
|
||||
from staging2.stg_process_table_IHTSLL_SLL
|
||||
where block_tag='IHTSLL_SLL_Lead_Lag' and block_row_number=10;
|
||||
|
||||
insert into staging2.IHTSLL_SLL_H1_INT (c1,c2)
|
||||
select 'Test Purpose',column10
|
||||
from staging2.stg_process_table_IHTSLL_SLL a
|
||||
where column3='Test Purpose' and block_tag='IHTSLL_SLL_Weight_Tyre';
|
||||
|
||||
update staging2.IHTSLL_SLL_H1_Int set model=__model;
|
||||
execute 'update staging2.IHTSLL_SLL_H1_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
insert into staging2.IHTSLL_SLL_H1_Block
|
||||
(
|
||||
dummy_f,
|
||||
Test_Request_no,
|
||||
Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Tractor_Model,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date,
|
||||
No_of_Sample,
|
||||
Test_Start_Date,
|
||||
Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_Location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
Remarks,
|
||||
Test_Purpose
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{c2}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[c2::text]) AS val
|
||||
FROM staging2.IHTSLL_SLL_H1_INT
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,
|
||||
a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,
|
||||
a_18 text,a_19 text,a_20 text);
|
||||
|
||||
|
||||
delete from staging2.IHTSLL_SLL_H1_Block where dummy_f is null ;
|
||||
update staging2.IHTSLL_SLL_H1_Block set model=__model;
|
||||
execute 'update staging2.IHTSLL_SLL_H1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTSLL_SLL_H1_BLOCK');
|
||||
|
||||
|
||||
insert into staging2.IHTSLL_SLL_Weight_Tyre_Int
|
||||
(
|
||||
column3,column6,column10,column11,column13,column15,column17,column19,
|
||||
column20,block_row_number
|
||||
)
|
||||
select
|
||||
column3,column6,column10,column11,column13,column15,column17,column19,
|
||||
column20,block_row_number
|
||||
from staging2.stg_process_table_IHTSLL_SLL a
|
||||
where block_tag='IHTSLL_SLL_Weight_Tyre'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTSLL_SLL_Weight_Tyre_Int set model=__model;
|
||||
execute 'update staging2.IHTSLL_SLL_Weight_Tyre_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
/*block starts - IHTSLL_SLL_Weight_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTSLL_SLL_Weight_Block',__file_mnemonic,__file_sheet_mnemonic,2);
|
||||
err_block:='IHTSLL_SLL_Weight_Block';
|
||||
insert into staging2.IHTSLL_SLL_Weight_Block
|
||||
(
|
||||
dummy_f,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg,
|
||||
Front_Reaction_kg,
|
||||
Rear_Reaction_kg,
|
||||
Left_Reaction_FL_RL_kg,
|
||||
Right_reaction_FR_RR_kg,
|
||||
Front_Left_Reaction_kg,
|
||||
Front_Right_Reaction_kg,
|
||||
Rear_Left_Reaction_kg,
|
||||
Rear_Right_Reaction_kg,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column6}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column6::text]) AS val
|
||||
FROM staging2.IHTSLL_SLL_Weight_Tyre_Int
|
||||
ORDER BY generate_series(1,15),block_row_number,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text,
|
||||
a_10 text,a_11 text);
|
||||
|
||||
delete from staging2.IHTSLL_SLL_Weight_Block where dummy_f is null ;
|
||||
update staging2.IHTSLL_SLL_Weight_Block set model=__model;
|
||||
execute 'update staging2.IHTSLL_SLL_Weight_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTSLL_SLL_Weight_Block');
|
||||
|
||||
/*block starts - IHTSLL_SLL_Tyre_Details_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTSLL_SLL_Tyre_Details_Block',__file_mnemonic,__file_sheet_mnemonic,3);
|
||||
err_block:='IHTSLL_SLL_Tyre_Details_Block';
|
||||
insert into staging2.IHTSLL_SLL_Tyre_Details_Block
|
||||
(
|
||||
dummy_f,
|
||||
Tyre_Details,
|
||||
Tyre_Make,
|
||||
Tyre_size,
|
||||
Ply_Rating,
|
||||
Load_Carrying_Capacity,
|
||||
Pressure_kg_cm2,
|
||||
Dynamic_rolling_radius,
|
||||
Static_rolling_radius,
|
||||
Wheel_rim_Make_size
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column15,column19}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column15::text,column19::text]) AS val
|
||||
FROM staging2.IHTSLL_SLL_Weight_Tyre_Int where block_row_number between 3 and 11
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text);
|
||||
|
||||
delete from staging2.IHTSLL_SLL_Tyre_Details_Block where dummy_f is null ;
|
||||
update staging2.IHTSLL_SLL_Tyre_Details_Block set model=__model;
|
||||
execute 'update staging2.IHTSLL_SLL_Tyre_Details_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTSLL_SLL_Tyre_Details_Block');
|
||||
|
||||
|
||||
/*block starts - IHTSLL_SLL_Wheel_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTSLL_SLL_Wheel_Block',__file_mnemonic,__file_sheet_mnemonic,4);
|
||||
err_block:='IHTSLL_SLL_Wheel_Block';
|
||||
insert into staging2.IHTSLL_SLL_Wheel_Block(dummy_f) values ('dummy');
|
||||
|
||||
update staging2.IHTSLL_SLL_Wheel_Block
|
||||
set Wheel_Base=(select column13 from
|
||||
staging2.IHTSLL_SLL_Weight_Tyre_Int
|
||||
where block_row_number=1 and column10='Wheel Base in mm')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update staging2.IHTSLL_SLL_Wheel_Block
|
||||
set Rear_Track_Width=(select column20 from
|
||||
staging2.IHTSLL_SLL_Weight_Tyre_Int
|
||||
where block_row_number=1 and column17='Rear Track Width in mm')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update staging2.IHTSLL_SLL_Wheel_Block set model=__model;
|
||||
execute 'update staging2.IHTSLL_SLL_Wheel_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTSLL_SLL_Wheel_Block');
|
||||
|
||||
/*block starts - IHTSLL_SLL_Forward_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTSLL_SLL_Forward_Block',__file_mnemonic,__file_sheet_mnemonic,5);
|
||||
err_block:='IHTSLL_SLL_Forward_Block';
|
||||
|
||||
insert into staging2.IHTSLL_SLL_Forward_Block
|
||||
(
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,block_row_number
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,block_row_number
|
||||
from staging2.stg_process_table_IHTSLL_SLL a
|
||||
where block_tag='IHTSLL_SLL_Forward'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTSLL_SLL_Forward_Block
|
||||
set column2=(select split_part(column3,'-',3)
|
||||
from staging2.IHTSLL_SLL_Forward_Block where block_row_number =1);
|
||||
|
||||
delete from staging2.IHTSLL_SLL_Forward_Block where column3 is null;
|
||||
|
||||
|
||||
update staging2.IHTSLL_SLL_Forward_Block set model=__model;
|
||||
execute 'update staging2.IHTSLL_SLL_Forward_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
update staging2.IHTSLL_SLL_Forward_Block set trx_record =0 where block_row_number in (1,2);
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTSLL_SLL_Forward_Block');
|
||||
|
||||
/*block starts - IHTSLL_SLL_Reverse_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTSLL_SLL_Reverse_Block',__file_mnemonic,__file_sheet_mnemonic,6);
|
||||
|
||||
err_block:='IHTSLL_SLL_Reverse_Block';
|
||||
|
||||
insert into staging2.IHTSLL_SLL_Reverse_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,block_row_number
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,block_row_number
|
||||
from staging2.stg_process_table_IHTSLL_SLL a
|
||||
where block_tag='IHTSLL_SLL_Reverse'
|
||||
order by block_row_number;
|
||||
|
||||
update staging2.IHTSLL_sll_reverse_block
|
||||
set column2=(select split_part(column3,' ',8)
|
||||
from staging2.IHTSLL_sll_reverse_block where block_row_number =1);
|
||||
|
||||
delete from staging2.IHTSLL_sll_reverse_block where column3 is null;
|
||||
|
||||
update staging2.IHTSLL_SLL_Reverse_Block set model=__model;
|
||||
execute 'update staging2.IHTSLL_SLL_Reverse_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
update staging2.IHTSLL_SLL_Reverse_Block set trx_record =0 where block_row_number in (1,2);
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTSLL_SLL_Reverse_Block');
|
||||
|
||||
/*block starts - IHTSLL_SLL_Lead_Lag_Block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTSLL_SLL_Lead_Lag_Block',__file_mnemonic,__file_sheet_mnemonic,7);
|
||||
err_block='IHTSLL_SLL_Lead_Lag_Block';
|
||||
insert into staging2.IHTSLL_SLL_Lead_Lag_Block
|
||||
(
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,block_row_number
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,block_row_number
|
||||
from staging2.stg_process_table_IHTSLL_SLL a
|
||||
where block_tag='IHTSLL_SLL_Lead_Lag'
|
||||
order by block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTSLL_SLL_Lead_Lag_Block a
|
||||
set column3= b.first_value from (SELECT
|
||||
block_row_number, column3, value_partition, first_value(column3) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column3,
|
||||
sum(case when column3 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTSLL_SLL_Lead_Lag_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number = b.block_row_number;
|
||||
|
||||
update staging2.IHTSLL_SLL_Lead_Lag_Block a
|
||||
set column4= b.first_value from (SELECT
|
||||
block_row_number, column4, value_partition, first_value(column4) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column4,
|
||||
sum(case when column4 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTSLL_SLL_Lead_Lag_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number = b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTSLL_SLL_Lead_Lag_Block a
|
||||
set column7= b.first_value from (SELECT
|
||||
block_row_number, column7, value_partition, first_value(column7) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column7,
|
||||
sum(case when column7 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTSLL_SLL_Lead_Lag_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number = b.block_row_number;
|
||||
|
||||
|
||||
update staging2.IHTSLL_SLL_Lead_Lag_Block a
|
||||
set column8= b.first_value from (SELECT
|
||||
block_row_number, column8, value_partition, first_value(column8) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column8,
|
||||
sum(case when column8 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTSLL_SLL_Lead_Lag_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number = b.block_row_number;
|
||||
|
||||
update staging2.IHTSLL_SLL_Lead_Lag_Block set model=__model;
|
||||
execute 'update staging2.IHTSLL_SLL_Lead_Lag_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
|
||||
update staging2.IHTSLL_SLL_Lead_Lag_Block set trx_record =0 where block_row_number in (1,2,3);
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTSLL_SLL_Lead_Lag_Block');
|
||||
|
||||
/*block starts - IHTSLL_SLL_Footer_block */
|
||||
|
||||
perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHTSLL_SLL_Footer_block',__file_mnemonic,__file_sheet_mnemonic,8);
|
||||
err_block:='IHTSLL_SLL_Footer_block';
|
||||
insert into staging2.IHTSLL_SLL_Footer_block(dummy_f) values ('dummy');
|
||||
|
||||
update staging2.IHTSLL_SLL_Footer_block a
|
||||
set prepared_by=( select column7 from staging2.stg_process_table_IHTSLL_SLL b
|
||||
where b.block_tag='IHTSLL_SLL_Footer'
|
||||
and lower(column3)='prepared by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTSLL_SLL_Footer_block a
|
||||
set reviewed_by=( select column7 from staging2.stg_process_table_IHTSLL_SLL b
|
||||
where b.block_tag='IHTSLL_SLL_Footer'
|
||||
and lower(column3)='reviewed by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTSLL_SLL_Footer_block a
|
||||
set approved_by=( select column7 from staging2.stg_process_table_IHTSLL_SLL b
|
||||
where b.block_tag='IHTSLL_SLL_Footer'
|
||||
and lower(column3)='approved by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTSLL_SLL_Footer_block a
|
||||
set comments=( select column3 from staging2.stg_process_table_IHTSLL_SLL b
|
||||
where b.block_tag='IHTSLL_SLL_Footer'
|
||||
and block_row_number=5 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTSLL_SLL_Footer_block a
|
||||
set rev1=( select column3 from staging2.stg_process_table_IHTSLL_SLL b
|
||||
where b.block_tag='IHTSLL_SLL_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
update staging2.IHTSLL_SLL_Footer_block a
|
||||
set rev2=( select column9 from staging2.stg_process_table_IHTSLL_SLL b
|
||||
where b.block_tag='IHTSLL_SLL_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTSLL_SLL_Footer_block a
|
||||
set rev3=( select column18 from staging2.stg_process_table_IHTSLL_SLL b
|
||||
where b.block_tag='IHTSLL_SLL_Footer'
|
||||
and block_row_number=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTSLL_SLL_Footer_block a
|
||||
set replaces=( select column19 from staging2.stg_process_table_IHTSLL_SLL b
|
||||
where b.block_tag='IHTSLL_SLL_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTSLL_SLL_Footer_block a
|
||||
set revision_no=( select column19 from staging2.stg_process_table_IHTSLL_SLL b
|
||||
where b.block_tag='IHTSLL_SLL_Footer'
|
||||
and block_row_number=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTSLL_SLL_Footer_block a
|
||||
set prepared_date=( select column16 from staging2.stg_process_table_IHTSLL_SLL b
|
||||
where b.block_tag='IHTSLL_SLL_Footer'
|
||||
and block_row_number=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTSLL_SLL_Footer_block a
|
||||
set reviewed_date=( select column16 from staging2.stg_process_table_IHTSLL_SLL b
|
||||
where b.block_tag='IHTSLL_SLL_Footer'
|
||||
and block_row_number=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTSLL_SLL_Footer_block a
|
||||
set approved_date=( select column16 from staging2.stg_process_table_IHTSLL_SLL b
|
||||
where b.block_tag='IHTSLL_SLL_Footer'
|
||||
and block_row_number=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update staging2.IHTSLL_SLL_Footer_block set model=__model;
|
||||
execute 'update staging2.IHTSLL_SLL_Footer_block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_mnemonic='''||p_file_mnemonic||''',
|
||||
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
|
||||
|
||||
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTSLL_SLL_Footer_block');
|
||||
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'stg2', 'fn_IHTSLL_SLL_block', err_state, err_msg, err_detail, err_hint, err_context,'success');
|
||||
|
||||
end
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user