aggregate function - Mailing list pgsql-sql

From Viktor Bojović
Subject aggregate function
Date
Msg-id AANLkTimo+SiM1VKiNM5V9tO4YMewn9+EoGV6NdJOpx+3@mail.gmail.com
Whole thread Raw
Responses Re: aggregate function  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
I am trying to make aggregate function of existing function which looks like this.
CREATE OR REPLACE FUNCTION "grafika"."pov_sphere" (x numeric, y numeric, z numeric, rad numeric, pigment varchar) RETURNS varchar AS
$body$
DECLARE
_pov varchar;
BEGIN
_pov:='sphere {<'||x||','||y||','||z||'>,'||rad||' '||pigment ||'}';
return _pov;
END;
$body$
LANGUAGE 'plpgsql'
IMMUTABLE
RETURNS NULL ON NULL INPUT
SECURITY INVOKER
COST 100;


Aggregate should concatenate results of pov_sphere using this function below.
CREATE OR REPLACE FUNCTION "public"."concat" (varchar, varchar) RETURNS varchar AS
$body$
DECLARE
t varchar;
BEGIN
IF character_length($1) > 0 THEN
t = $1 || $2;
ELSE
t = $2;
END IF;
RETURN t;
END;
$body$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100;


I tried to write this part below, but something is wrong (ERROR: function grafika.pov_sphere(character varying, numeric, numeric, numeric, numeric, character varying) does not exist) so I wanted to ask if someone knows how to solve this problem.

CREATE AGGREGATE "grafika"."agg_pov_sphere" (NUMERIC, NUMERIC, NUMERIC, NUMERIC, VARCHAR) (
SFUNC = "grafika"."pov_sphere",
STYPE = "varchar",
FINALFUNC = "public"."grp_concat"
);

Thanx in advance.
--
---------------------------------------
Viktor Bojović
---------------------------------------
Wherever I go, Murphy goes with me

pgsql-sql by date:

Previous
From: Rainer Stengele
Date:
Subject: Re: grouping subsets
Next
From: Tom Lane
Date:
Subject: Re: aggregate function