Re: Help me do a LOOP - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Help me do a LOOP
Date
Msg-id 43A921A8.3010702@archonet.com
Whole thread Raw
In response to Help me do a LOOP  (Calin Meze <mezecalin@yahoo.com>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: vishal saberwal
Date:
Subject: Re: [GENERAL] Question on indexes
Next
From: Richard Huxton
Date:
Subject: Re: Commiting after certain no of rows have been deleted