mc cursor is select /*+ parallel(24) */ pattern_nf, pattern_city, pid, uid_ from schema_xyz.pattern_ges_like;
mc2 cursor is SELECT /*+ parallel(24) */ pattern_nf, pattern_city, pid, uid_ from schema_xyz.pattern_ges_like where pattern_city='%';
ac cursor is SELECT /*+ parallel(24) */ address_full, address_full_uf, city, adr_id from schema_xyz.zzz_unkodierte where city is not null and not address_full=address_full_uf;
ac2 cursor is SELECT /*+ parallel(24) */ address_full, address_full_uf, city, adr_id from schema_xyz.zzz_unkodierte where city is null and not address_full=address_full_uf;
ac3 cursor is SELECT /*+ parallel(24) */ address_full, address_full_uf, city, adr_id from schema_xyz.zzz_unkodierte_II where city is not null and not address_full=address_full_uf;
ac4 cursor is SELECT /*+ parallel(24) */ address_full, address_full_uf, city, adr_id from schema_xyz.zzz_unkodierte_II where city is null and not address_full=address_full_uf;
ac5 CURSOR IS select /*+ parallel(24) */ address_full, city, adr_id from schema_xyz.zzz_unkodierte_I where city is not NULL;
ac6 CURSOR IS select /*+ parallel(24) */ address_full, city, adr_id from schema_xyz.zzz_unkodierte_I where city is NULL;
test_str varchar;
muster RECORD;
adresse RECORD;
Begin
raise notice 'prozess name: %s', prozess_name ;
raise notice 'table_out: %s', table_out ;
execute 'drop table if exists '||table_out||'';
EXECUTE 'create table '||table_out||'(address_full varchar not null, pattern_nf varchar not null, city varchar,
pattern_city varchar, adr_id numeric not null, pid numeric not null, uid_ numeric not null, reason varchar)';
/* +++++++ If city is not null, everything can be assigned as usual (sample comparison for address and city) +++++++ */
and address_full like '''||muster.pattern_nf||''' and city like '''||muster.pattern_city||''')';
commit;
END LOOP;
/* +++++++ If city is null, only the patterns with pattern_city='%' are unproblematic, others should not be used. This case does not occur with WoS. */
and address_full like '''||muster.pattern_nf||''')';
commit;
END LOOP;
/* +++++++ Additional step for pattern_matching: * all those that are not yet coded and have 'UNIV' in the address * are rotated again and then compared with the patterns. Intermediate table for this: schema_xyz.zzz_unkodierte. +++++++ */
execute 'drop index if exists schema_xyz.i_result_ii_adr_id';
execute 'drop index if exists schema_xyz.i_result_iii_adr_id';
execute 'drop index if exists schema_xyz.i_result_iii_uid_';
execute 'drop index if exists schema_xyz.i_result_iii_address_full';
execute 'drop index if exists schema_xyz.i_result_iii_city';
commit;
execute 'create index i_result_ii_adr_id on schema_xyz.result_II(adr_id)';
commit;
execute 'create index i_result_iii_adr_id on schema_xyz.result_III(adr_id)';
commit;
execute 'create index i_result_iii_uid_ on schema_xyz.result_III(uid_)';
commit;
execute 'create index i_result_iii_address_full on schema_xyz.result_III(address_full)';
commit;
execute 'create index i_result_iii_city on schema_xyz.result_III(city)';
commit;
EXECUTE 'insert into schema_xyz.process_info select '''||process_name||''', ''...indexes on result_iii done'', '''||current_timestamp::varchar||'''';
commit;
execute 'drop table if exists schema_xyz.zzz_unkodierte';
EXECUTE 'create table schema_xyz.zzz_unkodierte as (
select adr_id,address_full,city, '''' as address_full_uf
from schema_xyz.result_II
where not adr_id in (select adr_id from schema_xyz.result_III)
and address_full like ''%,%UNIV%'')';
commit;
execute 'create index on schema_xyz.zzz_unkodierte(address_full)';
commit;
execute 'create index on schema_xyz.zzz_unkodierte(address_full_uf)';
commit;
execute 'create index on schema_xyz.zzz_unkodierte(city)';
commit;
EXECUTE 'insert into schema_xyz.process_info select '''||process_name||''', ''......creation of schema_xyz.zzz_unkodierte done'', '''||current_timestamp::varchar||'''';
commit;
EXECUTE 'update schema_xyz.zzz_unkodierte set address_full_uf=schema_xyz.univ_first_pg(address_full)';
commit;
EXECUTE 'delete from schema_xyz.zzz_unkodierte where address_full_uf is null';
commit;
EXECUTE 'insert into schema_xyz.process_info select '''||process_name||''', ''univ_first done'', '''||current_timestamp::varchar||'''';
EXECUTE 'insert into schema_xyz.process_info select '''||process_name||''', ''Additional step uncoded: turn so that the UNIV part is at the front'', '''||current_timestamp::varchar||'''';
execute 'insert into schema_xyz.process_info select '''||process_name||''', ''Start additional step uncoded: all NF patterns ending in .% can also end directly (without .%)'', '''||current_timestamp::varchar||'''';
commit;
execute 'drop table if exists schema_xyz.zzz_unkodierte_I';
execute 'create table schema_xyz.zzz_unkodierte_I as (
select a.adr_id,a.address_full,a.city
from schema_xyz.result_II a
left join schema_xyz.result_iii b
on a.adr_id = b.adr_id
where b.adr_id is null)';
commit;
EXECUTE 'insert into schema_xyz.process_info select '''||process_name||''', ''......creation of schema_xyz.zzz_unkodierte_I done'', '''||current_timestamp::varchar||'''';
/* +++++++ Additional step for pattern_matching: compare all those that * have not yet been coded with the original address again, * in the event that very special patterns were present; for example, patterns that contain spelling errors, etc.
Intermediate table for this: schema_xyz.zzz_unkodierte_II. +++++++ */
execute 'drop table if exists schema_xyz.zzz_unkodierte_II';
/*EXECUTE 'create table schema_xyz.zzz_unkodierte_II(address_full varchar not null, city varchar,
adr_id varchar not null, address_full_original varchar, address_full_uf varchar)';*/
execute 'drop index if exists schema_xyz.i_result_ii_adrid';
execute 'create index i_result_ii_adrid on schema_xyz.result_II(adr_id)';
commit;
EXECUTE 'insert into schema_xyz.process_info select '''||process_name||''', ''...adr_id index on result_ii created'', '''||current_timestamp::varchar||'''';
commit;
execute 'drop index if exists schema_xyz.i_result_i_address_full';
execute 'create index i_result_i_address_full on schema_xyz.result_I(address_full)';
EXECUTE 'insert into schema_xyz.process_info select '''||process_name||''', ''...address full index on result_i created'', '''||current_timestamp::varchar||'''';
commit;
execute 'drop table if exists schema_xyz.zzz_unkodierte_II_pre';
execute 'create table schema_xyz.zzz_unkodierte_II_pre as (
select a.adr_id, a.address_full
from schema_xyz.result_ii a
left join schema_xyz.result_iii b
on a.adr_id=b.adr_id
where b.adr_id is null)';
commit;
EXECUTE 'insert into schema_xyz.process_info select '''||process_name||''', ''...create zzz_II_pre done'', '''||current_timestamp::varchar||'''';
commit;
execute 'drop index if exists schema_xyz.i_zzz_ii_pre';
execute 'create index i_zzz_ii_pre on schema_xyz.zzz_unkodierte_II_pre(address_full)';
commit;
execute 'drop table if exists schema_xyz.zzz_unkodierte_II';
execute 'create table schema_xyz.zzz_unkodierte_II as (
select b.adr_id,a.address_full,a.city,upper(address_full_original) as address_full_original,
upper(a.address_full_original) as address_full_uf
from schema_xyz.result_i a
join schema_xyz.zzz_unkodierte_II_pre b
on a.address_full = b.address_full)';
commit;
EXECUTE 'insert into schema_xyz.process_info select '''||process_name||''', ''...create zzz_II done'', '''||current_timestamp::varchar||'''';
commit;
EXECUTE 'insert into schema_xyz.process_info select '''||process_name||''', ''...indexes zzz_II done'', '''||current_timestamp::varchar||'''';
commit;
EXECUTE 'update schema_xyz.zzz_unkodierte_II
set address_full_uf=replace(address_full_uf,'''''''','''')';
EXECUTE 'insert into schema_xyz.process_info select '''||Process_name||''', ''End of additional step unencoded: Use originals'', '''||current_timestamp::varchar||'''';
commit;
/* +++++++ Grouping for the intermediate result +++++++ */
EXECUTE 'drop table if exists '||table_out_II||'';
EXECUTE 'create table '||table_out_II||' as (select address_full, city,