X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 01FCC9DC823 for ; Wed, 21 Dec 2005 05:38:51 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 84339-06 for ; Wed, 21 Dec 2005 05:38:52 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id C3B209DC80C for ; Wed, 21 Dec 2005 05:38:48 -0400 (AST) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id DA36040C1ED; Wed, 21 Dec 2005 09:34:27 +0000 (GMT) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id CEF1B15EA4; Wed, 21 Dec 2005 09:34:32 +0000 (GMT) Message-ID: <43A921A8.3010702@archonet.com> Date: Wed, 21 Dec 2005 09:34:32 +0000 From: Richard Huxton User-Agent: Thunderbird 1.5 (X11/20051025) MIME-Version: 1.0 To: Calin Meze Cc: pgsql-sql@postgresql.org Subject: Re: Help me do a LOOP References: <20051214082130.36637.qmail@web52809.mail.yahoo.com> In-Reply-To: <20051214082130.36637.qmail@web52809.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.007 required=5 tests=[AWL=0.007] X-Spam-Score: 0.007 X-Spam-Level: X-Archive-Number: 200512/190 X-Sequence-Number: 23732 Calin Meze wrote: > I need to test each record of a cursor for some requirements, > something like this [snip] > -- the problem is that I do not know how to make the while loop > execute until the last record "WHILE (still in the cursor)"... So I > need something like > > > Can anyone help me with this? It really seems silly... but I cannot > get to solve this, I do not know where to look for syntax like this > or tutorials like this. Assuming this is plpgsql you are probably looking for the FOUND pseudo-variable. See Ch 36.6.6 Obtaining the Result Status You don't actually need to bother with a cursor in plpgsql, just loop over a SELECT (Ch 36.7.4 Looping Through Query Results). That basically *is* a cursor internally. -- Richard Huxton Archonet Ltd