CREATE OR REPLACE FUNCTION insert_url(in_url text) RETURNS integer AS $$
BEGIN
	PERFORM * FROM artist_website aw
	WHERE aw.url = in_url;

    IF FOUND THEN
        RETURN 1;
    END IF;

	INSERT INTO artist_website (url) VALUES (in_url);
	
	CALL set_artist_name(in_url);
	CALL set_website_name(in_url);
	CALL set_folder_path(in_url);

	RETURN 0;
END;
$$ LANGUAGE plpgsql STRICT;