Hi All.
I'm writing a plpgsql function that creates a table and loops over the
items in that table, using a FOR ... IN EXECUTE ... loop. The thing is, on
each iteration I update the table over which I am looping. Sometimes, the
result of this update makes it no longer necessary/desirable to process
subsequent records in the loop.
My results are confusing me, and I was wondering if it is possible that my
method doesn't work considering how postgres holds query results in memory
for loops. I read somewhere that it caches several records at a time,
retrieving more as needed. If this is the case (is it?), and I updated a
field of an item that is already cached, would I then see that change when
I retrieved that item in the loop?
I feel like this is a difficult concept to illustrate with words. Perhaps
my pl/pgsql vocabulary is still too small for asking this question, but I'm
hoping that someone here can see my concern and tell me whether or not I am
barking up the right tree, so to speak.
Thanks,
Meghan