Skip to content
Snippets Groups Projects
Commit 9c006b02 authored by Christopher Lenke's avatar Christopher Lenke
Browse files

23.09.2024

parent 7325882e
No related branches found
No related tags found
No related merge requests found
-- DROP PROCEDURE schema_xyz.wostransfo_proc_pg(text, int8);
CREATE OR REPLACE PROCEDURE schema_xyz.wostransfo_proc_pg(input_table text, art bigint)
LANGUAGE plpgsql
AS $procedure$
BEGIN
DECLARE
/* Type=2: simple type: only wos_standard_plus Type=1: additionally insert wos_standard_plus_erg. Caution: takes a long time! (is not used)
city_cleaning: remove postcodes (they may interfere because they are not available in the city field in WoS) */
BEGIN
/* Rename address_full to address_full_original in the input table and create a new column address_full */
EXECUTE 'alter table '||input_table||' rename column address_full to address_full_original';
EXECUTE 'alter table '||input_table||' rename column city to city_original';
EXECUTE 'alter table '||input_table||' add address_full varchar';
EXECUTE 'alter table '||input_table||' add city varchar';
execute 'ALTER TABLE '||input_table||' SET UNLOGGED';
if (art=1) THEN
EXECUTE 'update /*+ parallel(24) */ '||input_table||' set address_full=schema_xyz.wos_transformation_pg(address_full_original,1)';
EXECUTE 'update /*+ parallel(24) */ '||input_table||' set city=schema_xyz.wos_transformation_pg(city_original,1)';
elsif (art=2) then
EXECUTE 'update /*+ parallel(24) */ '||input_table||' set address_full=schema_xyz.wos_transformation_pg(address_full_original,2)';
commit;
EXECUTE 'update /*+ parallel(24) */ '||input_table||' set city=schema_xyz.wos_transformation_pg(city_original,2)';
commit;
END IF;
if (art=1 or art=2) then
EXECUTE 'update /*+ parallel(24) */ '||input_table||' set city=schema_xyz.city_cleaning_pg(city)';
commit;
end if;
END;
END;
$procedure$
;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment