By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,834 Members | 2,265 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,834 IT Pros & Developers. It's quick & easy.

aggregate function

P: n/a
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.
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 11 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Claudio Lapidus" <cl******@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
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 11 '05 #2

P: n/a
Greg Stark wrote:
Is this example helpful?
Yes, perfect! Thank you.
cl.

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
);


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 11 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.