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
