modify sql functions
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
CREATE OR REPLACE PROCEDURE set_folder_path(in_url text) AS $$
|
||||
CREATE OR REPLACE FUNCTION public.set_folder_path(in_url text) RETURNS integer
|
||||
LANGUAGE plpgsql STRICT
|
||||
AS $$
|
||||
DECLARE
|
||||
temp_folder_path text;
|
||||
aw_artist_id integer;
|
||||
@ -9,18 +11,28 @@ BEGIN
|
||||
SELECT aw.artist_id INTO aw_artist_id FROM artist_website aw
|
||||
WHERE aw.url = in_url;
|
||||
|
||||
IF aw_artist_id IS NULL THEN
|
||||
RETURN 1;
|
||||
END IF;
|
||||
|
||||
SELECT aw.website_id INTO aw_website_id FROM artist_website aw
|
||||
WHERE aw.url = in_url;
|
||||
|
||||
IF aw_website_id IS NULL THEN
|
||||
RETURN 1;
|
||||
END IF;
|
||||
|
||||
SELECT artist.name INTO artist_name FROM artist
|
||||
WHERE artist.id = aw_artist_id;
|
||||
|
||||
SELECT website.name INTO website_name FROM website
|
||||
WHERE website.id = aw_website_id;
|
||||
|
||||
temp_folder_path = concat('Artist/', artist_name, '/', website_name);
|
||||
temp_folder_path = concat('Artists/', artist_name, '/', website_name);
|
||||
|
||||
UPDATE artist_website SET folder_path = temp_folder_path
|
||||
WHERE url = in_url;
|
||||
|
||||
RETURN 0;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
$$;
|
||||
|
Reference in New Issue
Block a user