Re: String aggregate function

Поиск
Список
Период
Сортировка
От Tomasz Myrta
Тема Re: String aggregate function
Дата
Msg-id 3E75A9BE.6080701@klaster.net
обсуждение исходный текст
Ответ на Re: String aggregate function  ("Objectz" <objectz@postmark.net>)
Ответы Re: String aggregate function  (Tomasz Myrta <jasiek@klaster.net>)
Список 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



В списке pgsql-sql по дате отправления:

Предыдущее
От: "Objectz"
Дата:
Сообщение: Re: String aggregate function
Следующее
От: Tomasz Myrta
Дата:
Сообщение: Re: String aggregate function