Received: from sziami.cs.bme.hu (sziami.cs.bme.hu [152.66.242.225]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0RJFiq76001 for ; Sat, 27 Jan 2001 14:15:44 -0500 (EST) (envelope-from nthomas@cs.bme.hu) Received: by sziami.cs.bme.hu (Postfix, from userid 2023) id D3B331374D; Sat, 27 Jan 2001 20:15:42 +0100 (CET) Date: Sat, 27 Jan 2001 20:15:42 +0100 From: Nagy Tamas To: pgsql-sql@postgresql.org Subject: looping through results of a SELECT Message-ID: <20010127201542.A1794@cs.bme.hu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i X-Archive-Number: 200101/416 X-Sequence-Number: 1092 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