CREATE OR REPLACE FUNCTION set_stuff() RETURNS trigger AS $$
DECLARE
	temp_url text;
BEGIN
	SELECT aw.url INTO temp_url FROM artist_website aw
	WHERE aw.id = NEW.id;

    IF NOT FOUND THEN
        RAISE EXCEPTION 'No url has been found';
    END IF;

	CALL set_artist_name(NEW.url);
	CALL set_website_name(NEW.url);
	CALL set_folder_path(NEW.url);
	
	RETURN NEW;
END;
$$ LANGUAGE plpgsql;

-- DROP TRIGGER IF EXISTS set_stuff_trigger ON artist_website;

CREATE OR REPLACE TRIGGER set_stuff_trigger AFTER INSERT ON artist_website
FOR EACH ROW EXECUTE PROCEDURE set_stuff();

ALTER TABLE artist_website ENABLE TRIGGER set_stuff_trigger;