Обсуждение: Looping through Arrays

Поиск
Список
Период
Сортировка

Looping through Arrays

От
adam lawrence
Дата:
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.

Re: Looping through Arrays

От
"Merlin Moncure"
Дата:
On 10/10/06, adam lawrence <name_adam@yahoo.com.au> wrote:
> 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?

FOR j IN array_lower(arrayvar, 2)..array_upper(arrayvar, 2) LOOP

:-)

merlin