Thread: Agregation Function

Agregation Function

From
Pierre-Yves LANDURE
Date:
Hi, i have to create an agregation function.. what is the syntax.

The function to be agregation is :

DROP FUNCTION "polygon_agregation"(polygon);
CREATE FUNCTION "polygon_agregation"(polygon) RETURNS box AS 'DECLARE
polygons_to_agregate ALIAS FOR $1
BEGIN
agregated_polygons = NULL;

FOR poly IN polygons_to_agregate LOOP
IF agregated_polygons = NULL THEN agregated_polygons = box(poly);
agregated_polygons = box(agregated_polygons, box(poly));
END LOOP;

RETURN agregated_polygons,
END' LANGUAGE 'plpgsql'

Thanx

Pierre-Yves Landuré