Describe a compute row’s row identifier and bylist.
CS_RETCODE srv_alt_header(spp, altid, numbylist, bylistarrayp) SRV_PROC *spp; CS_INT altid; CS_INT numbylist; CS_SMALLINT *bylistarrayp;
A pointer to an internal thread control structure.
A unique identifier for this compute row.
The number of columns in the bylist of a compute row.
A pointer to an array of column numbers that make up the bylist for a compute row. There are as many elements as specified in numbylist. If numbylist is 0, bylistarrayp is ignored.
Returns |
To indicate |
---|---|
CS_SUCCEED |
The routine completed successfully. |
CS_FAIL |
The routine failed. |
#include <ospublic.h>
/*
** Local Prototype
*/
CS_RETCODE ex_srv_alt_header PROTOTYPE((
SRV_PROC *spp
));
/*
** EX_SRV_ALT_HEADER
**
** Example routine to illustrate the use of srv_alt_header
** to describe a compute row’s row identifier and bylist.
**
** Arguments:
** spp - A pointer to an internal thread control structure.
**
** Returns:
**
** CS_SUCCEED A compute row was successfully described.
** CS_FAIL An error was detected.
*/
CS_RETCODE ex_srv_alt_header(spp)
SRV_PROC *spp;
{
CS_INT altid;
CS_SMALLINT bylist[2];
/*
** Let us describe a fictitious compute row with altid =1,
** and bylist = [2,4].
*/
altid = (CS_INT)1;
bylist[0] = (CS_SMALLINT)2;
bylist[1] = (CS_SMALLINT)4;
if (srv_alt_header(spp, altid,
sizeof(bylist)/sizeof(CS_SMALLINT),
bylist) == CS_FAIL)
return (CS_FAIL);
return (CS_SUCCEED);
}
Only applications that mimic Adaptive Server’s feature of returning compute row information will need to call srv_alt_header. srv_alt_header is most useful to applications acting as a gateway to an Adaptive Server.
srv_alt_header assigns a unique identifier to each compute row and describes the bylist associated with each compute row. It must be called once for each compute row.
In the Adaptive Server, compute rows result from the compute clause of a Transact- SQL select statement. If a Transact -SQL select statement contains multiple compute clauses, separate compute rows are generated by each clause. Open Server can return rows of compute data, mimicking an Adaptive Server’s response to a Transact- SQL compute clause.
A Transact -SQL select statement’s compute clause can 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 array in *bylistarrayp stores the number associated with each column in the bylist. That number is determined by the column’s position in the select statement. For example, if a column were the third item in the select statement, it would be listed as the number 3 in the array.
To process compute row data, an Open Server application must:
Call srv_alt_header to define a compute row identifier.
Call srv_alt_desc&fmt for each column to describe the format the column data is in when the client receives it.
Call srv_alt_bind for each column to bind the data to a local program variable.
Call srv_alt_xferdata to send the row to the client, once each column in the compute row has been described and its data bound to a program variable.