Re: Counting elements of an array

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Renaud Tthonnart <thonnart(at)amwdb(dot)u-strasbg(dot)fr>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Counting elements of an array
Date: 2001-03-01 15:40:30
Message-ID: 21173.983461230@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Renaud Tthonnart <thonnart(at)amwdb(dot)u-strasbg(dot)fr> writes:
> I would like to know how I can get the number of elements of an array.

There is a function that returns an array's dimensions as a text string:

regression=# select array_dims( '{1,2,3}'::int[] );
array_dims
------------
[1:3]
(1 row)

regression=# select array_dims( '{{1,2,3},{4,5,6}}'::int[] );
array_dims
------------
[1:2][1:3]
(1 row)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Denis Perchine 2001-03-01 15:40:45 Re: Postgres eats up memory when using cursors
Previous Message Bruce Momjian 2001-03-01 15:34:45 Re: Addison-Wesley looking for authors