kivitendo/sql/Pg-upgrade2/PgCommaAggregateFunction.sql @ master
0bb6aed5 | Udo Spallek | -- @tag: PgCommaAggregateFunction
|
||
-- @description: Neue Postgres Funktion zur Abfrage mehrdeutiger Ergebniszeilen als kommagetrennte Liste
|
||||
-- @depends: release_2_4_1
|
||||
-- Taken from: http://www.zigo.dhs.org/postgresql/#comma_aggregate
|
||||
3774d83b | Moritz Bunkus | -- Copyright © 2005 Dennis Björklund
|
||
0bb6aed5 | Udo Spallek | -- License: Free
|
||
-- Thx. to A. Kretschmer, http://archives.postgresql.org/pgsql-de-allgemein/2007-02/msg00006.php
|
||||
CREATE FUNCTION comma_aggregate(text,text) RETURNS text AS '
|
||||
SELECT CASE WHEN $1 <> '''' THEN $1 || '', '' || $2
|
||||
ELSE $2
|
||||
END;
|
||||
' LANGUAGE sql IMMUTABLE STRICT;
|
||||
CREATE AGGREGATE comma (basetype=text, sfunc=comma_aggregate, stype=text, initcond='' );
|