pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Johnston <polobo@yahoo.com>
To: 'mephysto' <mephystoonhell@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: Help in accessing array
Date: Tue, 2 Oct 2012 09:53:29 -0400
Message-ID: <00e901cda0a5$4de0d280$e9a27780$@yahoo.com> (raw)
In-Reply-To: <1348740741516-5725666.post@n5.nabble.com>
References: <1348740741516-5725666.post@n5.nabble.com>

> -----Original Message-----
> From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-
> owner@postgresql.org] On Behalf Of mephysto
> Sent: Thursday, September 27, 2012 6:12 AM
> To: pgsql-sql@postgresql.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.






view thread (2+ messages)

Message-ID: <00e901cda0a5$4de0d280$e9a27780$@yahoo.com>
Permalink:  ../00e901cda0a5$4de0d280$e9a27780$@yahoo.com/
Also on:    postgresql.org/message-id/00e901cda0a5$4de0d280$e9a27780$@yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: polobo@yahoo.com, mephystoonhell@gmail.com
  Subject: Re: Help in accessing array
  In-Reply-To: <00e901cda0a5$4de0d280$e9a27780$@yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox