pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Help in accessing array
2+ messages / 2 participants
[nested] [flat]

* Help in accessing array
@ 2012-09-27 10:12  mephysto <mephystoonhell@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: mephysto @ 2012-09-27 10:12 UTC (permalink / raw)
  To: pgsql-sql

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



--
View this message in context: http://postgresql.1045698.n5.nabble.com/Help-in-accessing-array-tp5725666.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Help in accessing array
@ 2012-10-02 13:53  David Johnston <polobo@yahoo.com>
  parent: mephysto <mephystoonhell@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: David Johnston @ 2012-10-02 13:53 UTC (permalink / raw)
  To: 'mephysto' <mephystoonhell@gmail.com>; pgsql-sql

> -----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.






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2012-10-02 13:53 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-09-27 10:12 Help in accessing array mephysto <mephystoonhell@gmail.com>
2012-10-02 13:53 ` David Johnston <polobo@yahoo.com>

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