Search Postgresql Archives

Accessing array elements in a FOR PL/pgsql loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For each element in the array, I need to make some operation with plpgsql.
I usually use the syntax:

DECLARE
 array_len int;
BEGIN
 array_len := array_upper(i_array, 1);
 FOR i IN 1 .. array_len
 LOOP
    SOME OPERATION (i_array[i])
 END LOOP;

But I don't like that. Is there any built-in way to do that without using the length, i.e like in python, e.g.
 for element in array:
   ....
This example does not work in Postgres.

I think I need a built-in function to make a column from an array, like in the backwards operation SELECT ARRAY(column)

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux