comparison schema/isrs_functions.sql @ 3731:0d45a3c34900

schema: Added function to detect string representation of ISRS codes.
author Sascha Wilde <wilde@intevation.de>
date Mon, 24 Jun 2019 11:21:41 +0200
parents 453f15ba8030
children e8b2dc771f9e
comparison
equal deleted inserted replaced
3730:d9ac1c56bfe0 3731:0d45a3c34900
208 RETURN result_geom; 208 RETURN result_geom;
209 END; 209 END;
210 $$ 210 $$
211 LANGUAGE plpgsql 211 LANGUAGE plpgsql
212 STABLE PARALLEL SAFE; 212 STABLE PARALLEL SAFE;
213
214
215 -- Check if a given string looks like an ISRS code
216 CREATE OR REPLACE FUNCTION is_ISRSstring(str text) RETURNS boolean
217 AS $$
218 BEGIN
219 str = upper(str);
220 RETURN (SELECT str SIMILAR TO '[A-Z]{2}[A-Z0-9]{13}[0-9]{5}')
221 AND is_country(substring(str from 1 for 2));
222 END;
223 $$
224 LANGUAGE plpgsql
225 IMMUTABLE PARALLEL SAFE;