CREATE FUNCTION create_seq(n integer) RETURNS integer
    LANGUAGE plpgsql
    AS $$
BEGIN
    WHILE n > 0 LOOP
        EXECUTE 'CREATE SEQUENCE test' || CAST(n AS TEXT);
      n := n - 1;
    END LOOP;
    RETURN 0;
END
$$;

CREATE FUNCTION currval_seq(n integer) RETURNS integer
    LANGUAGE plpgsql
    AS $_$
BEGIN
    WHILE n > 0 LOOP
        EXECUTE $$SELECT currval('test$$ || CAST(n AS TEXT) || $$')$$;
      n := n - 1;
    END LOOP;
    RETURN 0;
END
$_$;

CREATE FUNCTION drop_seq(n integer) RETURNS integer
    LANGUAGE plpgsql
    AS $$
BEGIN
    WHILE n > 0 LOOP
        EXECUTE 'DROP SEQUENCE test' || CAST(n AS TEXT);
      n := n - 1;
    END LOOP;
    RETURN 0;
END
$$;

CREATE OR REPLACE FUNCTION nextval_seq(n integer) RETURNS integer
    LANGUAGE plpgsql
    AS $_$
BEGIN
    WHILE n > 0 LOOP
        EXECUTE $$SELECT nextval('test$$ || CAST(n AS TEXT) || $$')$$;
        n := n - 1;
    END LOOP;
    RETURN 0;
END
$_$;


SELECT create_seq(10000);
SELECT nextval_seq(10000);
SELECT currval_seq(10000);

