create or replace type body my_aggregate_type
is
static function ODCIAggregateInitialize (start_context IN OUT my_aggregate_type)
return number
/* This function initializes the context of aggregation,
that is creates a new my_aggregate_type and initializes its attributes */
is
begin
start_context := my_aggregate_type (1);
return ODCIConst.Success;
end;
member function ODCIAggregateIterate (self IN OUT my_aggregate_type,
value IN number /* input type */)
return number
/* This function implements the aggregation algorithm */
is
begin
/* Follows the code to aggregate the preceding result with the current data */
/* In our example, this is just a product */
self.total := self.total * value;
return ODCIConst.Success;
end;
member function ODCIAggregateTerminate (self IN my_aggregate_type,
returnValue OUT number,
flags IN number)
return number
/* This function does the final stuff */
/* In our example, we make the square root */
is
begin
returnValue := sqrt (self.total);
return ODCIConst.Success;
end;
member function ODCIAggregateMerge (self IN OUT my_aggregate_type,
second_context IN my_aggregate_type)
return number
/* This function merge two contexts */
is
begin
/* Follows the code to merge two "sub-aggregations" */
self.total := self.total * second_context.total;
return ODCIConst.Success;
end;
end;
/
Pages: 1 · 2 · 3 · 4