Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: returning an array as a list fo single-column rows?



On Sun, Dec 23, 2007 at 10:19:26PM +0100, Pavel Stehule wrote:
> Hello
> 
> try
> 
> create or replace function unpack(anyarray)
> returns setof anyelement as $$
>   select $1[i]
>      from generate_series(array_lower($1,1), array_upper($1,1)) g(i);
> $$ language sql;
> 
> postgres=# select * from unpack(array[1,2,3,4]);
>  unpack
> --------
>       1
>       2
>       3
>       4
> (4 rows)

Beautiful. Thank you.



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group