Adriano dos Santos Fernandes <adrian...@gmail.com> wrote Sat, 29 Sep 2018
22:55:52 +0300:
So SUSPEND in this context is very like JS YIELD with caller doing a
reduce.
I have even thought in use YIELD keyword in this context.
Adriano
The keyword YEILD is more preferable for aggregate functions. At the same
time, the return type can be written as usual for functions, not
procedures.
create aggregate function custom_count (i integer) returns integer
as
declare accumulated integer cnt;
begin
cnt = 0;
while (not agg_finished)
do
begin
if (i is not null) then
cnt = cnt + 1;
yeild cnt;
end
end
create aggregate function custom_avg (i double precision) returns double
precision
as
declare accumulated cnt integer = 0;
declare accumulated double precision = 0;
declare result double precision = 0;
begin
while (not agg_finished)
do
begin
if (i is not null) then
begin
count = count + 1;
accumulated = accumulated + i;
result = accumulated / count;
end
yeild result;
end
end
--
Simonov Denis
Firebird-Devel mailing list, web interface at
https://lists.sourceforge.net/lists/listinfo/firebird-devel