From 88b993cf13cd00d417d5aabd6fa31c568bf138ac Mon Sep 17 00:00:00 2001 From: AustrianToast Date: Mon, 11 Nov 2024 21:18:30 +0100 Subject: [PATCH] actually needed that --- sql/get_urls_and_paths.sql | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 sql/get_urls_and_paths.sql diff --git a/sql/get_urls_and_paths.sql b/sql/get_urls_and_paths.sql new file mode 100644 index 0000000..f5d2eab --- /dev/null +++ b/sql/get_urls_and_paths.sql @@ -0,0 +1,16 @@ +CREATE OR REPLACE FUNCTION public.get_urls_and_paths(website_name text) RETURNS TABLE (out_url text, out_website_name text) + LANGUAGE plpgsql + AS $$ +BEGIN + RETURN QUERY SELECT aw.url, aw.folder_path + FROM artist_website aw + INNER JOIN website w ON aw.website_id = w.id + WHERE w.name ILIKE website_name; + + IF NOT FOUND THEN + RAISE EXCEPTION 'No urls and paths found for website: %', website_name; + END IF; + + RETURN; +END; +$$; \ No newline at end of file