Volltext-Suche: Tabelle für Texte aus Dateien im DMS. DB und Rose
[kivitendo-erp.git] / sql / Pg-upgrade2 / PgCommaAggregateFunction.sql
1 -- @tag: PgCommaAggregateFunction
2 -- @description: Neue Postgres Funktion zur Abfrage mehrdeutiger Ergebniszeilen als kommagetrennte Liste
3 -- @depends: release_2_4_1
4 -- Taken from: http://www.zigo.dhs.org/postgresql/#comma_aggregate
5 -- Copyright © 2005 Dennis Björklund
6 -- License: Free
7 -- Thx. to A. Kretschmer, http://archives.postgresql.org/pgsql-de-allgemein/2007-02/msg00006.php
8 CREATE FUNCTION comma_aggregate(text,text) RETURNS text AS '
9   SELECT CASE WHEN $1 <> '''' THEN $1 || '', '' || $2 
10                               ELSE $2 
11          END; 
12 ' LANGUAGE sql IMMUTABLE STRICT; 
13
14 CREATE AGGREGATE comma (basetype=text, sfunc=comma_aggregate, stype=text, initcond='' );
15