Re: aggregate functions - Mailing list pgsql-general

From Holger Klawitter
Subject Re: aggregate functions
Date
Msg-id 394DF677.92966CD3@klawitter.de
Whole thread Raw
In response to aggregate functions  (Holger Klawitter <holger@klawitter.de>)
Responses Re: aggregate functions  (Alex Pilosov <alex@pilosoft.com>)
List pgsql-general
> is there any easy way to add the string concatenation operator
> as a collating operator? I would like to do something like:

Blimey, I should have looked for "create aggregate".
But to those interested here is my solution.

create function
    joinfunc( text, text )
returns text as '
    begin
        if $1 = '''' then
            return $2;
        else
            return ( $1 || '', '' ) || $2;
        end if;
    end;
' language 'plpgsql';

create aggregate join (
    basetype = text,
    sfunc1 = joinfunc,
    stype1 = text,
    initcond1 = ''
);

Perhaps someone want to put that into the documentation.
By the way, there is still one problem:

    select join(col) group by ...
does not work, one has to type
    select "join"(col) group by ...

I assume this is bug ...

Regards,
    Holger Klawitter
--
Holger Klawitter                                    +49 (0)251 484 0637
holger@klawitter.de                            http://www.klawitter.de/


pgsql-general by date:

Previous
From: Joost Kraaijeveld
Date:
Subject: RE: Weird error on NT
Next
From: "Bryan White"
Date:
Subject: Re: Read an already existing DB: functions & triggers.