From 0bb6aed531f07d348ac70b7d6a47526e957485ed Mon Sep 17 00:00:00 2001 From: Udo Spallek Date: Fri, 2 Feb 2007 14:16:10 +0000 Subject: [PATCH] Neue Postgres Funktion zur Abfrage mehrdeutiger Ergebniszeilen als kommagetrennte Liste. Aufrufsyntax: SELECT comma(accno) FROM chart Ergebnismenge: 0027, 0090, 0200, 0210, 0380,... (1 Zeile) --- sql/Pg-upgrade2/PgCommaAggregateFunction.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 sql/Pg-upgrade2/PgCommaAggregateFunction.sql diff --git a/sql/Pg-upgrade2/PgCommaAggregateFunction.sql b/sql/Pg-upgrade2/PgCommaAggregateFunction.sql new file mode 100644 index 000000000..c2e10ae3e --- /dev/null +++ b/sql/Pg-upgrade2/PgCommaAggregateFunction.sql @@ -0,0 +1,15 @@ +-- @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 +-- Copyright © 2005 Dennis Björklund +-- 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='' ); + -- 2.20.1