From a6ba4e09a3e993074ebb525747bf806c229aa773 Mon Sep 17 00:00:00 2001 From: Christopher Lenke <christopher.lenke@uni-bielefeld.de> Date: Mon, 23 Sep 2024 19:18:34 +0200 Subject: [PATCH] 23.09.2024 --- .../get_adr_id_b_pg_varchar__varchar_.txt | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Functions/get_adr_id_b_pg_varchar__varchar_.txt diff --git a/Functions/get_adr_id_b_pg_varchar__varchar_.txt b/Functions/get_adr_id_b_pg_varchar__varchar_.txt new file mode 100644 index 0000000..0bd3db8 --- /dev/null +++ b/Functions/get_adr_id_b_pg_varchar__varchar_.txt @@ -0,0 +1,30 @@ +-- DROP FUNCTION schema_xyz.get_adr_id_b_pg(varchar, varchar); + +CREATE OR REPLACE FUNCTION schema_xyz.get_adr_id_b_pg(address_full_in character varying, city_in character varying) + RETURNS bigint + LANGUAGE plpgsql +AS $function$ + +DECLARE +/* +Returns an adr_id value for an address based on the result_II table (which must contain address_full, city and adr_id). +*/ +DECLARE + +ergebnis bigint; + +BEGIN + + +select /*+ parallel(auto) */ distinct(adr_id) into ergebnis +from schema_xyz.result_II a +join schema_xyz.result_I b +on a.address_full=b.address_full and coalesce(a.city,'0')=coalesce(b.city,'0') +where b.address_full_original=address_full_in and coalesce(b.city_original,'0')=coalesce(city_in,'0'); + +return ergebnis; + + +END; +$function$ +; -- GitLab