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

23.09.2024

parent 78d908e7
No related branches found
No related tags found
No related merge requests found
-- DROP FUNCTION schema_xyz.city_cleaning_pg(text);
CREATE OR REPLACE FUNCTION schema_xyz.city_cleaning_pg(spalte_in text)
RETURNS character varying
LANGUAGE plpgsql
AS $function$
DECLARE
ergebnis varchar;
city_cleaned varchar;
BEGIN
city_cleaned:=regexp_replace(upper(spalte_in),'D?E?O?W?-? ?[0-9]{4,6} ?',' ' , 'g');
city_cleaned:=regexp_replace(city_cleaned,'D?E?O?W?-? ?[0-9]{2,2} [0-9]{3,3} ?',' ' , 'g');
city_cleaned:=regexp_replace(city_cleaned,'D?E?o?W?-? ?[0-9]{3,3} [0-9]{2,2} ?',' ' , 'g');
city_cleaned:=ltrim(rtrim(city_cleaned));
city_cleaned:=replace(city_cleaned,', ', ' ');
city_cleaned:=replace(city_cleaned,' ', ' ');
city_cleaned:=replace(city_cleaned,' ', ' ');
if (city_cleaned like '%,')
then
city_cleaned:=substr(city_cleaned, 1, length(city_cleaned)-1);
end if;
city_cleaned:=ltrim(rtrim(city_cleaned));
city_cleaned:=regexp_replace(city_cleaned,'^[0-9]{1,3} ',' ' , 'g');
city_cleaned:=regexp_replace(city_cleaned,' [0-9]{1,3}$',' ' , 'g');
city_cleaned:=regexp_replace(city_cleaned,' [0-9]{1,3} ',' ' , 'g');
city_cleaned:=replace(city_cleaned,', ', ' ');
city_cleaned:=replace(city_cleaned,' ', ' ');
city_cleaned:=replace(city_cleaned,' ', ' ');
city_cleaned:=ltrim(rtrim(city_cleaned));
ergebnis:=city_cleaned;
RETURN ergebnis;
END;
$function$
;
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