Re: Help in accessing array

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'mephysto'" <mephystoonhell(at)gmail(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Help in accessing array
Date: 2012-10-02 13:53:29
Message-ID: 00e901cda0a5$4de0d280$e9a27780$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> -----Original Message-----
> From: pgsql-sql-owner(at)postgresql(dot)org [mailto:pgsql-sql-
> owner(at)postgresql(dot)org] On Behalf Of mephysto
> Sent: Thursday, September 27, 2012 6:12 AM
> To: pgsql-sql(at)postgresql(dot)org
> Subject: [SQL] Help in accessing array
>
> Hi to everyone,
> I have a little problem to retrieve data from multidimensional array. For
> example, if I have this array
>
> foo[][] = {{5,3},{2,2}}
>
> how can I retrieve one of two internal array (for example I would to
retrieve
> {5,3}?
>
> I tried foo[1:1] but the result is {{5,3}}, not {5,3}.
>
> Is a method to achieve my goal?
>
> Thanks in advance.
>
> Mephysto

IIRC

You cannot de-dimension an array (aside from the special-case single
dimension, 1 value, case). You will need to unnest the array into
components, filter those components, then go from there. Each,
"unnest(array)" call explodes one dimension. Consider wraping things in a
function to make the code cleaner.

David J.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Samuel Gendler 2012-10-02 19:57:08 Re: [noob] How to optimize this double pivot query?
Previous Message Robert Buck 2012-10-02 09:45:32 Re: [noob] How to optimize this double pivot query?