loop with circular updates - Mailing list pgsql-general

From Jessica M Salmon
Subject loop with circular updates
Date
Msg-id OFB38A84F4.BBFB72A2-ON872571B6.00775029-872571B6.00781153@fs.fed.us
Whole thread Raw
Responses Re: loop with circular updates
List pgsql-general
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


pgsql-general by date:

Previous
From: "Tom Kinard"
Date:
Subject: Database Restore errors
Next
From: "chris997"
Date:
Subject: Re: "Ghost" colmumn with primary key