470,614 Members | 1,386 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,614 developers. It's quick & easy.

Concurrency and use of setval()

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.


Jul 19 '05 #1
0 2963

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Charlie Williams | last post: by
4 posts views Thread by Robert Schuldenfrei | last post: by
4 posts views Thread by Bob | last post: by
7 posts views Thread by William E Voorhees | last post: by
5 posts views Thread by John | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.