drop function if exists transactional.fn_run_updates;
CREATE OR REPLACE FUNCTION transactional.fn_run_updates(p_client_id int,p_function_id int)
   RETURNS void AS $$
   begin
-- Update location at test_insstance table:
update transactional.test_instance 
set test_location_name = 'BUDNI'
where file_mnemonic = 'BUDNI' ;

update transactional.test_instance 
set test_location_name = 'MRV Test Track'
where file_mnemonic in ('DBSTD', 'DBOECD');

update transactional.test_instance 
set test_location_name = 'MRV Test Track'
where file_mnemonic like 'IHT%';

update transactional.test_instance 
set test_location_name = 'MRV'
where file_mnemonic like 'PTO%';

update transactional.test_instance 
set season = TO_CHAR(
    TO_DATE (extract( month from date_of_test)::text, 'MM'), 'Month'
    ) 
where season is null
and file_mnemonic in ('FTDRY','FTWET');

update transactional.test_instance 
set date_of_test = test_report_date
where date_of_test is null
and file_mnemonic like 'IHT%';



update transactional.test_instance 
set date_of_test = test_end_date
where date_of_test is null
and file_mnemonic like 'IHT%';



end;
$$  LANGUAGE plpgsql;
