Oracle® Database Data Cartridge Developer's Guide, 10g Release 2 (10.2) Part Number B14289-02 |
|
|
PDF · Mobi · ePub |
This chapter describes the routines that need to be implemented to define a user-defined aggregate function. The routines are implemented as methods in an object type. Then the CREATE FUNCTION
statement is used to actually create the aggregate function.
This chapter contains the following topics:
See Also:
Chapter 11, "User-Defined Aggregate Functions"The methods in this section are implemented as methods in an object type. The CREATE FUNCTION
statement is used to actually create the aggregate function. Table 22-1 summarizes these functions.
Table 22-1 Summary of User-Defined Aggregate Functions
Function | Description |
---|---|
Initializes the aggregation context and instance of the implementation object type, and returns it as an |
|
Iterates through input rows by processesing the input values, updating and then returning the aggregation context. |
|
Merges two aggregation contexts into a single object instance during either serial or parallel evaluation of the user-defined aggregate. |
|
Calculates the result of the aggregate computation and performs all necessary cleanup, such as freeing memory. |
|
Removes an input value from the current group. |
|
Integrates all external pieces of the current aggregation context to make the context self-contained. |
Initializes the aggregation context and instance of the implementation object type, and returns it as an OUT
parameter. F Implement this routine as a static method.
STATIC FUNCTION ODCIAggregateInitialize( actx IN OUT <impltype>) RETURN NUMBER
Parameter | In/Out | Description |
---|---|---|
actx |
IN OUT |
The aggregation context that is initialized by the routine. This value is NULL for regular aggregation cases. In aggregation over windows, actx is the context of the previous window. This object instance is passed in as a parameter to the next aggregation routine. |
ODCIConst.Success
on success, or ODCIConst.Error
on error.
Iterates through input rows by processesing the input values, updating and then returning the aggregation context. Invoked for each value, including NULL
s. This is a mandatory routine and is implemented as a member method.
MEMBER FUNCTION ODCIAggregateIterate( self IN OUT <impltype>, val <inputdatatype>) RETURN NUMBER;
Parameter | IN/OUT | Description |
---|---|---|
self |
IN OUT |
As input, the value of the current aggregation context; as output, the updated value. |
val |
IN |
The input value which is being aggregated. |
ODCIConst.Success
on success, or ODCIConst.Error
on error.
Merges two aggregation contexts into a single object instance during either serial or parallel evaluation of the user-defined aggregate. This is a mandatory routine and is implemented as a member method.
MEMBER FUNCTION ODCIAggregateMerge( self IN OUT <impltype>, ctx2 IN <impltype>) RETURN NUMBER;
Parameter | IN/OUT | Description |
---|---|---|
self |
IN OUT |
On input, the value of the first aggregation context; on output, the resulting value of the two merged aggregation contexts. |
ctx2 |
IN |
The value of the second aggregation context. |
ODCIConst.Success
on success, or ODCIConst.Error
on error.
Calculates the result of the aggregate computation and performs all necessary cleanup, such as freeing memory. Invoked by Oracle as the last step of aggregate computation. This is a mandatory routine and is implemented as a member method.
MEMBER FUNCTION ODCIAggregateTerminate( self IN <impltype>, ReturnValue OUT <return_type>, flags IN number) RETURN NUMBER;
ODCIConst.Success
on success, or ODCIConst.Error
on error.
See Aso:
"Reusing the Aggregation Context for Analytic Functions" on page 11-6 for details on setting theODCI_AGGREGATE_REUSE_CTX
flag bit.Removes an input value from the current group. The routine is invoked by Oracle by passing in the aggregation context and the value of the input to be removed during It processes the input value, updates the aggregation context, and returns the context. This is an optional routine and is implemented as a member method.
MEMBER FUNCTION ODCIAggregateDelete( self IN OUT <impltype>, val <inputdatatype>) RETURN NUMBER;
Parameter | IN/OUT | Description |
---|---|---|
self |
IN OUT |
As input, the value of the current aggregation context; as output, the updated value. |
val |
IN |
The input value which is being removed from the current group. |
ODCIConst.Success
on success, or ODCIConst.Error
on error.
Integrates all external pieces of the current aggregation context to make the context self-contained. Invoked by Oracle if the user-defined aggregate has been declared to have external context and is transmitting partial aggregates from slave processes. This is an optional routine and is implemented as a member method.
MEMBER FUNCTION ODCIAggregateWrapContext( self IN OUT <impltype>) RETURN NUMBER;
Parameter | IN/OUT | Description |
---|---|---|
self |
IN |
On input, the value of the current aggregation context; on output, the self-contained combined aggregation context. |
ODCIConst.Success
on success, or ODCIConst.Error
on error.
See Also:
"Handling Large Aggregation Contexts" on page 11-4 for more information on using this function