Re: array iteration?

From: Ben <bench(at)silentmedia(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: array iteration?
Date: 2003-11-24 00:36:54
Message-ID: Pine.LNX.4.44.0311231636021.7403-100000@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hey, that's cool. When did those functions arrive?

On Sun, 23 Nov 2003, Tom Lane wrote:

> Ben <bench(at)silentmedia(dot)com> writes:
> > On Sat, 2003-11-22 at 12:44, CSN wrote:
> >> Is it possible to iterate over an array in plpgsql?
>
> > Yep.
> > http://archives.postgresql.org/pgsql-general/2003-11/msg00852.php
>
> The cited example is pretty iffy since it assumes that the valid array
> entries are all > 0. In recent PG version you can use the array_upper
> and array_lower functions instead:
>
> for i in array_lower(a,1) .. array_upper(a,1) loop
> -- do something with a[i]
> end loop;
>
> regards, tom lane
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Randolf Richardson, DevNet SysOp 29 2003-11-24 00:49:31 Re: Export CSV from psql
Previous Message Stephen Robert Norris 2003-11-23 23:39:48 7.4 Python configure hosed