Oracle® Database Data Cartridge Developer's Guide 11g Release 2 (11.2) Part Number E10765-01 |
|
|
View PDF |
This chapter describes the routines that must 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:
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 |
---|---|
Removes an input value from the current group. |
|
Initializes the aggregation context and instance of the implementation object type, and returns it as an |
|
Iterates through input rows by processing 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. |
|
Integrates all external pieces of the current aggregation context to make the context self-contained. |
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.
Syntax
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 that is being removed from the current group. |
Returns
ODCIConst.Success
on success, or ODCIConst.Error
on error.
Initializes the aggregation context and instance of the implementation object type, and returns it as an OUT
parameter. Implement this routine as a static method.
Syntax
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. |
Returns
ODCIConst.Success
on success, or ODCIConst.Error
on error.
Iterates through input rows by processing 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.
Syntax
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 that is being aggregated. |
Returns
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.
Syntax
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. |
Returns
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.
Syntax
MEMBER FUNCTION ODCIAggregateTerminate( self IN <impltype>, ReturnValue OUT <return_type>, flags IN number) RETURN NUMBER
Returns
ODCIConst.Success
on success, or ODCIConst.Error
on error.
See Also:
"Reusing the Aggregation Context for Analytic Functions" for details on setting theODCI_AGGREGATE_REUSE_CTX
flag bit.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.
Syntax
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. |
Returns
ODCIConst.Success
on success, or ODCIConst.Error
on error.
See Also:
"Handling Large Aggregation Contexts" for more information on using this function