chore(*.psql/*.sql): update all *.psql to *.sql files
This commit is contained in:
parent
c9015a7f2b
commit
fc37600b8b
63 changed files with 21 additions and 41 deletions
21
queries/functions/parse_country_field.sql
Normal file
21
queries/functions/parse_country_field.sql
Normal file
|
@ -0,0 +1,21 @@
|
|||
CREATE OR REPLACE FUNCTION normalize_country_field(countryField TEXT)
|
||||
RETURNS TEXT AS $$
|
||||
DECLARE
|
||||
delimiters TEXT[] := ARRAY[',', '/', '&', 'and'];
|
||||
countries TEXT[];
|
||||
temp TEXT[];
|
||||
result TEXT := '';
|
||||
i INTEGER;
|
||||
BEGIN
|
||||
countries := string_to_array(countryField, ',');
|
||||
FOR i IN 1..array_length(delimiters, 1) LOOP
|
||||
temp := ARRAY[]::TEXT[];
|
||||
FOREACH result IN ARRAY countries LOOP
|
||||
temp := array_cat(temp, string_to_array(result, delimiters[i]));
|
||||
END LOOP;
|
||||
countries := temp;
|
||||
END LOOP;
|
||||
result := array_to_string(countries, ' ');
|
||||
RETURN trim(result);
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
Loading…
Add table
Add a link
Reference in a new issue