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