Re: array iteration?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Ben <bench(at)silentmedia(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: array iteration?
Date: 2003-11-25 03:56:23
Message-ID: 200311250356.hAP3uNo14748@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ben wrote:
> Hey, that's cool. When did those functions arrive?

I think 7.4. We had a lot of nice array stuff added.

>
> 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
> >
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Venkatesh R Ramteke 2003-11-25 05:01:38 unsubscribe
Previous Message Christopher Browne 2003-11-25 02:58:05 Re: Where is Postgesql ? - MYSQL SURPRISES WITH MAXDB /