It is customary to restrict emails to a single list or at least make others aware when you do have a legitmate need to cross-post.Specifically your post on -admin <“Break” in plpgsql Function - PostgreSQL 9.2>Yes, it didn't belong on -admin in the first place but posting it here with a different title and not indicating on either thread that the other exists and/or is the valid one just makes it harder for others to follow along.
Sorry about that. It wasn't on purpose... It won't happen again.
As for your general question I try to approach this problem in the following manner:SELECT however many of something that you need (FOR UPDATE)UPDATE those selected to indicate that they have been seenPROCESS them as neededrepeat step 1 until it returns no recordsIt doesn't always work - and given a sufficiently large number of records it may be unadvisable - but it is set-oriented which is generally a plus in SQL.The other way to assign batches is to use the integer modulus operator (e.g., 10 % 3 = 1 : read 3 remainder of 1) or integer division (10 / 3 = 3) to derive the batch number based upon an attribute of the data itself as opposed to its order of appearance in a result set.David J.