From: | Tomasz Myrta <jasiek(at)klaster(dot)net> |
---|---|
To: | Objectz <objectz(at)postmark(dot)net> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: String aggregate function |
Date: | 2003-03-17 10:55:58 |
Message-ID: | 3E75A9BE.6080701@klaster.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Uz.ytkownik Objectz napisa?:
> Tomsaz,
>
> Thnx a lot for the great reference It has what I need.
>
> create function comma_aggregate(text,text) returns text as '
> begin
> if (length($1) > 0 ) then
> return $1 || ', ' || $2;
> else
> return $2;
> end if;
> end;
> ' language 'plpgsql';
>
> -- create the aggregate function
>
> create aggregate comma (basetype=text, sfunc=comma_aggregate,
> stype=text, initcond='' );
>
>
> I need some help to expand on its funcitonality instead of calling
> comma(col_name) to produce comma-seperated values I need to call
> something like concattext(prefix, col_name, suffix) wich returns the
> list in one column with the prefix and suffix aroung each entry as
> specified.
>
> This will enable me to produce something like this result
>
>
>>1 (text1) (text3)
>>2 (text2) (text5)
>>3 (text4)
>
>
> With this query
> Select type, concattext('(', text, ') ') from table group by type
>
> Any help on how to convert the above comma function to receive the
> prefix and suffix parameters
>
> Regards
Change this function to separate fields only with space character
(instead of comma) and use as below:
select comma('(' || text ')') ...
Regards,
Tomasz Myrta
From | Date | Subject | |
---|---|---|---|
Next Message | Tomasz Myrta | 2003-03-17 10:59:10 | Re: String aggregate function |
Previous Message | Objectz | 2003-03-17 10:35:30 | Re: String aggregate function |