looping through results of a SELECT

From: Nagy Tamas <nthomas(at)cs(dot)bme(dot)hu>
To: pgsql-sql(at)postgresql(dot)org
Subject: looping through results of a SELECT
Date: 2001-01-27 19:15:42
Message-ID: 20010127201542.A1794@cs.bme.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello!

I'd like to write a function, that makes some calculations
(perhaps applies another function) on every row of a result set returned
by a SELECT query. I thought writing a WHILE loop would work, but I
couldn't assign the individual rows to a variable. Then, I read about the
FETCH command, and I tried to use that, but it dies with 'error
near CURSOR' error when I try to use the function. I wrote a PL/PGSQL
function, obviously. So, my question is: is there an easy way to assign
the individual rows of a SELECT result to a variable in a function?
Thanks in advance,
Thomas Nagy

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Davis 2001-01-27 21:04:00 RE: looping through results of a SELECT
Previous Message Tom Lane 2001-01-27 16:20:52 Re: wrong query plan in 7.1beta3