Files
HDB/sql/get_all_convertable_paths.sql
2024-11-11 20:20:49 +01:00

25 lines
622 B
PL/PgSQL

CREATE OR REPLACE FUNCTION public.get_all_convertable_paths() RETURNS Table (bad_path text, good_path text)
LANGUAGE plpgsql STRICT
AS $$
DECLARE
url text;
artist_name text;
temp_bad_path text;
temp_good_path text;
BEGIN
FOR url IN
SELECT aw.url FROM artist_website aw
LOOP
artist_name = get_artist_name(url);
temp_bad_path = concat('Artists/', artist_name);
temp_good_path = concat('Artists/', convert_artist_name(artist_name));
PERFORM * FROM artist WHERE artist.name = artist_name;
IF NOT FOUND THEN
RETURN QUERY SELECT temp_bad_path,temp_good_path;
END IF;
END LOOP;
END;
$$;