From: Richard Huxton <dev@archonet.com>
To: Calin Meze <mezecalin@yahoo.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Help me do a LOOP
Date: Wed, 21 Dec 2005 09:34:32 +0000
Message-ID: <43A921A8.3010702@archonet.com> (raw)
In-Reply-To: <20051214082130.36637.qmail@web52809.mail.yahoo.com>
References: <20051214082130.36637.qmail@web52809.mail.yahoo.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, mezecalin@yahoo.com
Subject: Re: Help me do a LOOP
In-Reply-To: <43A921A8.3010702@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox