Re: display array field as row

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: hendra kusuma <penguinroad(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: display array field as row
Date: 2009-02-03 05:23:29
Message-ID: 162867790902022123y2ffd9d48hd19cf5cbd6d8161d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmail(dot)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
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-02-03 05:30:54 Re: Smartest way to resize a column?
Previous Message Phoenix Kiula 2009-02-03 04:21:06 Re: Smartest way to resize a column?