arbitrary number of values from a sequence - Mailing list pgsql-general

From Gyozo Papp
Subject arbitrary number of values from a sequence
Date
Msg-id 007301c0d4b2$e2d43880$3b46c5d5@jaguar
Whole thread Raw
Responses Re: arbitrary number of values from a sequence  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
hello,

I'd like to know if there is any possible solution to allocate arbitrary number of *subsequent values* from a sequence.
I mean it in the following way:

ie.: The sequence 'seq' is at 1234 for the current ...
=#select nextval('seq');

nextval
-------
   1234

and I need 5 five subsequent values (from 1234 to 1238), - in other words - a range with a length of 5 from the current
value.I thought this simple trick could do the job : 

=#select setval('seq', (select nextval('seq')) + 5);

My question:
is it good if 'seq' can be used concurrently by multiple backends, or is there any other point from that it can be
dangerous/ harmful? 

Papp Gyozo
- pgerzson@freestart.hu


pgsql-general by date:

Previous
From: "Roderick A. Anderson"
Date:
Subject: Re: Invoices
Next
From: Bruce Momjian
Date:
Subject: Re: Ideal hardware configuration for pgsql