On 08/11/2010 01:54 PM, David E. Wheeler wrote:
On Aug 11, 2010, at 10:53 AM, Robert Haas wrote:

Iterating through an array with plpgsql, for example, is more clunky
than it should be.
Really?

FOR var IN SELECT UNNEST(arr) LOOP ... END LOOP

I mean, doing everything is sort of clunky in PL/pgsql, but this
doesn't seem particularly bad as PL/pgsql idioms go.
That tends to over-flatten if you have nested arrays and just want to iterate 
over the top level. In that case you must use generate_subscripts().


for i in array_lower(myarray,1) .. array_upper(myarray,1) loop ...

works well

cheers

andrew



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

Reply via email to