arbitrary number of values from a sequence

From: "Gyozo Papp" <pgerzson(at)freestart(dot)hu>
To: <pgsql-general(at)postgresql(dot)org>
Subject: arbitrary number of values from a sequence
Date: 2001-05-04 15:37:14
Message-ID: 007301c0d4b2$e2d43880$3b46c5d5@jaguar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)freestart(dot)hu

Responses

Browse pgsql-general by date

  From Date Subject
Next Message HYip 2001-05-04 15:48:00 select error with null string -- error code -209
Previous Message Roderick A. Anderson 2001-05-04 15:31:38 Re: Invoices