From: | Ramesh T <rameshparnanditech(at)gmail(dot)com> |
---|---|
To: | rod(at)iol(dot)ie |
Cc: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, Pavel Stěhule <pavel(dot)stehule(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Collection |
Date: | 2015-02-14 12:58:57 |
Message-ID: | CAK8Zd=sMviE+90xekETz36d_cmSWUXW-m_xkwUVkv-LtTcLeyA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
i solved my problem using string_agg in tab_to_string
ex:-
select string_agg(s.Rnumber ::text,',' )AS number
On Fri, Feb 13, 2015 at 10:40 PM, Raymond O'Donnell <rod(at)iol(dot)ie> wrote:
> On 13/02/2015 13:13, Ramesh T wrote:
> > cast(COLLECT (r_id) as num) in oracle..
> >
> > is their *collect *function in postgres plpgsql....?or any alternate
> > for this..?
>
> I don't use Oracle, but I think array_agg() is the closest - it
> aggregates the column into an array.
>
> postgres=# create table test(a integer, b text);
> CREATE TABLE
> postgres=# insert into test values (1, 'abc');
> INSERT 0 1
> postgres=# insert into test values (2, 'def');
> INSERT 0 1
> postgres=# insert into test values (2, 'ghi');
> INSERT 0 1
> postgres=# select a, array_agg(b) from test group by a;
> a | array_agg
> ---+-----------
> 1 | {abc}
> 2 | {def,ghi}
> (2 rows)
>
>
> Ray.
>
> --
> Raymond O'Donnell :: Galway :: Ireland
> rod(at)iol(dot)ie
>
From | Date | Subject | |
---|---|---|---|
Next Message | Berend Tober | 2015-02-14 13:07:44 | Re: How to hide stored procedure's bodies from specific user |
Previous Message | AI Rumman | 2015-02-14 02:42:10 | increasing varchar column size is taking too much time |