aggregate function

Started by Claudio Lapidusover 22 years ago3 messagesgeneral
Jump to latest
#1Claudio Lapidus
clapidus@hotmail.com

Hello

I would like to know how can I define/create a new aggregate function. I
need a custom function that operate on a set of text strings and return a
certain string aggregate based on certain rules. But I cannot figure out how
can I define such a data set to operate on.

any hints?

cl.

#2Bruce Momjian
bruce@momjian.us
In reply to: Claudio Lapidus (#1)
Re: aggregate function

"Claudio Lapidus" <clapidus@hotmail.com> writes:

Hello

I would like to know how can I define/create a new aggregate function. I
need a custom function that operate on a set of text strings and return a
certain string aggregate based on certain rules. But I cannot figure out how
can I define such a data set to operate on.

Is this example helpful?

create function concat_agg_accum(varchar, varchar) returns varchar
as 'select $1 || '', '' || $2'
language sql
strict immutable;

create aggregate concat_agg (
basetype = varchar,
stype = varchar,
sfunc = concat_agg_accum
);

--
greg

#3Claudio Lapidus
clapidus@hotmail.com
In reply to: Claudio Lapidus (#1)
Re: aggregate function

Greg Stark wrote:

Is this example helpful?

Yes, perfect! Thank you.
cl.

Show quoted text

create function concat_agg_accum(varchar, varchar) returns varchar
as 'select $1 || '', '' || $2'
language sql
strict immutable;

create aggregate concat_agg (
basetype = varchar,
stype = varchar,
sfunc = concat_agg_accum
);