loop with circular updates

From: Jessica M Salmon <jmsalmon(at)fs(dot)fed(dot)us>
To: pgsql-general(at)postgresql(dot)org
Subject: loop with circular updates
Date: 2006-07-25 21:51:27
Message-ID: OFB38A84F4.BBFB72A2-ON872571B6.00775029-872571B6.00781153@fs.fed.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message MC Moisei 2006-07-25 22:21:28 Re: Mapping/DB Migration tool
Previous Message Reece Hart 2006-07-25 21:49:34 Re: Mapping/DB Migration tool