![]() | ![]() |
Home |
|
|
Open Client Client-Library/C Reference Manual |
|
| Chapter 3 Routines |
|
| ct_compute_info |
|
| Usage |
Table 3-10 summarizes ct_compute_info usage.
Value of type | Value of colnum | Information retrieved | *buffer is set to | *outlen is set to |
CS_BYLIST_LEN | CS_UNUSED | The number of elements in the bylist array | An integer valu. | sizeof(CS_INT) |
CS_COMP_BYLIST | CS_UNUSED | An array containing the bylist that produced this compute row | An array of CS_SMALLINT values | The length of the array, in bytes |
CS_COMP_COLID | The column number of the compute column | The select-list column ID of the column from which the compute column derives | An integer value | sizeof(CS_INT) |
CS_COMP_ID | CS_UNUSED | The compute ID for the current compute row | An integer value | sizeof(CS_INT) |
CS_COMP_OP | The column number of the compute column | The aggregate operator type for the compute column | One of the following symbolic values: CS_OP_SUM CS_OP_AVG CS_OP_COUNT CS_OP_MIN CS_OP_MAX | sizeof(CS_INT) |
Compute rows result from the compute clause of a select statement. A compute clause generates a compute row every time the value of its by column-list changes. A compute row contains one column for each aggregate operator in the compute clause. If a select statement contains multiple compute clauses, separate compute rows are generated by each clause.
Each compute row returned by the server is considered to be a distinct result set. That is, each result set of type CS_COMPUTE_RESULT will contain exactly one row.
It is only legal to call ct_compute_info when compute information is available; that is, after ct_results returns CS_COMPUTE_RESULT or CS_COMPUTEFMT.
Each section below contains information about a particular type of compute result information.
A select statement's compute clause may contain the keyword by, followed by a list of columns. This list, known as the bylist, divides the results into subgroups, based on changing values in the specified columns. The compute clause's aggregate operators are applied to each subgroup, generating a compute row for each subgroup.
The select-list column ID for a compute column is the position within the select-list of the column from which the compute column derives.
A SQL select statement can have multiple compute clauses, each of which returns a separate compute row. The compute ID corresponding to the first compute clause in a select statement is 1.
When called with type as CS_COMP_OP, ct_compute_info sets *buffer to one of the following aggregate operator types:
*buffer setting | Meaning |
CS_OP_AVG | Average aggregate operator |
CS_OP_COUNT | Count aggregate operator |
CS_OP_MAX | Maximum aggregate operator |
CS_OP_MIN | Minimum aggregate operator |
CS_OP_SUM | Sum aggregate operato. |
|
|