Re: string_to_array with an empty input string - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: string_to_array with an empty input string
Date
Msg-id 4C62E4E1.4000505@dunslane.net
Whole thread Raw
In response to Re: string_to_array with an empty input string  ("David E. Wheeler" <david@kineticode.com>)
Responses Re: string_to_array with an empty input string  ("David E. Wheeler" <david@kineticode.com>)
List pgsql-hackers

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
mustuse generate_subscripts().
 


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

works well

cheers

andrew




pgsql-hackers by date:

Previous
From: "David E. Wheeler"
Date:
Subject: Re: string_to_array with an empty input string
Next
From: "David E. Wheeler"
Date:
Subject: Re: string_to_array with an empty input string