--
-- util__multiple_nextval/2
--
create or replace function util__multiple_nextval(
  character varying,
  integer
) returns varchar as $$

declare
  v_sequence_name        alias for $1;  
  v_count                alias for $2;  
  a_sequence_values      text default ''; 
  v_rec                  record;
begin
    for counter in 1..v_count loop
        for v_rec in EXECUTE 'select ' || quote_ident(v_sequence_name) '.nextval as a_seq_val'
        LOOP
           a_sequence_values := a_sequence_values || '','' || v_rec.a_seq_val;
          exit;
        end loop;
    end loop;

    return substr(a_sequence_values, 2);
 
end;$$ language plpgsql;