By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,512 Members | 707 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,512 IT Pros & Developers. It's quick & easy.

Concurrency and use of setval()

P: n/a
I want to allocate a contiguous block of ID's from a sequence generator.

My concern is that between the time I call
nextval() to get the start of the block and setval() to set a new
starting seqence number past the end of the block that some parallel
computation may already have called nexval() and allocated something
within my block, or setval().

How can I execute a nextval(),setval() pair under synchronized control?

The only thing I can thing of is

SELECT setval('foo', nextval()+20) ...

Is there any guarantee that the two functions will act under the control
of a synchronized whole in the server executation environment?

Sometimes it's important to be able to obtain a contiguous block of IDs
to avoid fragmenting other tables that express multiple receords for
discontiguous record sequences.

Thanks...

Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.