number of elements in a multidimensional array

Started by SunWuKungover 19 years ago3 messagesgeneral
Jump to latest
#1SunWuKung
Balazs.Klein@t-online.hu

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

#2SunWuKung
Balazs.Klein@t-online.hu
In reply to: SunWuKung (#1)
Re: number of elements in a multidimensional array

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]*)]$')

#3David Fetter
david@fetter.org
In reply to: SunWuKung (#1)
Re: number of elements in a multidimensional array

On Thu, Aug 31, 2006 at 08:17:35AM -0700, 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?

SELECT array_upper('{{1,4,10,11},{1,5,4,5}}'::TEXT[], 2);

Cheers,
D
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter

Remember to vote!