Looping through Arrays - Mailing list pgsql-general

From adam lawrence
Subject Looping through Arrays
Date
Msg-id 20061010075516.54746.qmail@web27209.mail.ukl.yahoo.com
Whole thread Raw
Responses Re: Looping through Arrays  ("Merlin Moncure" <mmoncure@gmail.com>)
List pgsql-general
Hi

I want to be able to loop through an array. The code I have used in the past is:

FOR i IN array_lower(arrayvar,1) .. array_upper(arrayvar,1) LOOP
currentvalue:=arrayvar[1][i];
RAISE NOTICE '%', currentvalue;
END LOOP;

But now I need to loop through the whole array, not just the one element. I want to do something like:

FOR j in ....LOOP
    FOR i IN array_lower(arrayvar,1) .. array_upper(arrayvar,1) LOOP
    currentvalue:=arrayvar[j][i];
    RAISE NOTICE '%', currentvalue;
    END LOOP;
END LOOP;

How to I set the upper and lower bounds for j?



Yahoo! Messenger - with free PC-PC calling and photo sharing.

pgsql-general by date:

Previous
From: "Christian Kasprowicz"
Date:
Subject: Storing Procedures / Transactions
Next
From: "woonhak kang"
Date:
Subject: Problem with executing PostgreSQL on Embedded Linux