Re: HOWTO: select * from array_type - Mailing list pgsql-general

From Pavel Stehule
Subject Re: HOWTO: select * from array_type
Date
Msg-id 162867790809152245y17c1f8a0nfe9650618e39a3ab@mail.gmail.com
Whole thread Raw
In response to HOWTO: select * from array_type  (alefajnie <devphyl@gmail.com>)
List pgsql-general
Hello

you need SQL function upack

create or replace function unpack(anyarray)
returns setof anyelement as $$
select $1[i]
   from generate_series(array_lover($1,1), array_upper($1,1)) g(i)
$$ language sql strict immutable;

postgres=# select * from unpack('{one, two, three}'::text[]);
 unpack
--------
 one
 two
 three
(3 rows)

regards
Pavel Stehule

2008/9/11 alefajnie <devphyl@gmail.com>:
> hey
>
> I have : (A)
> select (string_to_array(mycolumn, ' ')) from mytable  where id = sth;
>
> and here receive:
> {'one', 'two', 'three'}
> 1 row
>
> but I want 3 rows with data:
> 'one'
> 'two'
> 'three'
>
>
> how make second select of above (A) ?
>
> btw: is any subtrace on psql arrays ?
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

pgsql-general by date:

Previous
From: pcreso@pcreso.com
Date:
Subject: foreign key problem
Next
From: Simon Riggs
Date:
Subject: Re: about partitioning