Re: number of elements in a multidimensional array

From: "SunWuKung" <Balazs(dot)Klein(at)t-online(dot)hu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: number of elements in a multidimensional array
Date: 2006-09-01 10:42:30
Message-ID: 1157107350.264541.114260@p79g2000cwp.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


SunWuKung wrote:
> >From this array how could I get back the fact that this array consists
> of a two dimensional array with X elements?
>
> Select array_dims('{{1,4,10,11},{1,5,4,5}}'::text [])
>
> I would like to get back the number 4 here?
>
> Thanks for the help.
> Balázs

This is what I came up with finally, not very elegant but seems to do
the job:
Select substring(array_dims('{{1,4,10,11},{1,5,4,5}}'::text []) from
'([0-9]*)]$')

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-09-01 11:12:51 Re: Create user or role from inside a function?
Previous Message Stefan Kaltenbrunner 2006-09-01 10:40:53 Re: [pgsql-advocacy] Thought provoking piece on