Choose your SQL server:
AnySQL
MySQL
MS SQL Server
PostgreSQL
Oracle
SQL Anywhere
DB2
SQLite
Firebird
MaxDB

Subscribe to our newsletter

PostgreSQL Maestro online Help

Prev  Return to chapter overview Next 

Specifying aggregate options

Several options can be specified for the aggregate function that govern the expected behaviour of the function. The detailed description is given below.

 

Owner

Defines the owner of the new aggregate. By default, only the owner of an object can perform various operations with the object. In order to allow other users to operate it, privileges must be granted. (However, users that have the superuser attribute can always access any object.)

 

Comment

The box allows you to set optional text to describe the new aggregate.

 

Base Type

The field is used for setting the input data type on which this aggregate function operates. This can be specified as "ANY" for an aggregate that does not examine its input values (an example is count(*)).

 

State Type

The data type for the state value of the aggregate.

 

State Function

The name of the state transition function to be called for each input data value. This is normally a function of two arguments, the first being of type state type and the second of type base type. Alternatively, for an aggregate that does not examine its input values, the function takes just one argument of type state type. In either case the function must return a value of type state type. This function takes the current state value and the current input data item, and returns the next state value.

 

Final Function

The name of the final function called to compute the aggregate's result after all input data has been traversed. The function must take a single argument of type state type. The return data type of the aggregate is defined as the return type of this function. If final function is not specified, then the ending state value is used as the aggregate result, and the return type is state type.

 

Initial Condition

The initial setting for the state value. This must be a string constant in the form accepted for the data type state type. If not specified, the state value starts out null.



Prev  Return to chapter overview Next