Re: display array field as row - Mailing list pgsql-general

From Pavel Stehule
Subject Re: display array field as row
Date
Msg-id 162867790902022123y2ffd9d48hd19cf5cbd6d8161d@mail.gmail.com
Whole thread Raw
In response to display array field as row  (hendra kusuma <penguinroad@gmail.com>)
List pgsql-general
Hello

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

select conname, contype, unnest(conkey) from ...

regards
Pavel Stehule

2009/2/3 hendra kusuma <penguinroad@gmail.com>:
> Dear all,
>
> Does anyone know how to display an array data into row?
> for exampla, I have data like this
>
> conname contype conkey
>
>
> kelas_pkey p {1,2}
>
>
> kelas_tahun f {2}
>
>
>
> And I want to to display those data above like below
>
> kelas_pkey     p     1
> kelas_pkey     p     2
> kelas_tahun   f      2
>
> Do you know any sql syntax that would do?
> I cannot find it in documentation
> or is it not possible?
>
> Regards
> Hendra
>

pgsql-general by date:

Previous
From: Phoenix Kiula
Date:
Subject: Re: Smartest way to resize a column?
Next
From: Tom Lane
Date:
Subject: Re: Smartest way to resize a column?