If I want to allocate a block of adjacent values from a sequence generator, is the following statement atomic with respect to the time between when the call to nextval() and setval()?

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

The goal is to get a sequence of 20 values that are all +1 from each other.

If the above isn't safe in concurrent environments, is there something else I can
do to achieve the effect safely?


I saw a similar unanswered question on one of the PostgreSQL newsgroups,
and have a need to do the same thing from my JDBC app.

Tips appreciated.










---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Reply via email to