Describe the aggregate operator of a compute row column and the format of the column data returned to the client.
CS_RETCODE srv_alt_descfmt(spp, altid, optype, operand, item, clfmtp) SRV_PROC *spp; CS_INT altid; CS_INT optype; CS_TINYINT operand; CS_INT item; CS_DATAFMT *clfmtp;
A pointer to an internal thread control structure.
The unique identifier for the compute row in which this compute column is contained. The altid is defined using srv_alt_header.
The column’s column number in the compute row. Compute row column numbers start at 1.
The aggregate operator type of the compute row column. The following table lists the legal operator types:
Operator type |
Function |
---|---|
CS_OP_COUNT |
Count aggregate operator |
CS_OP_SUM |
Sum aggregate operator |
CS_OP_AVG |
Average aggregate operator |
CS_OP_MIN |
Minimum aggregate operator |
CS_OP_MAX |
Maximum aggregate operator |
The select-list column the aggregate is operating on.
A pointer to the CS_DATAFMT structure. This structure describes the format the column data is in when the client receives it.
Returns |
To indicate |
---|---|
CS_SUCCEED |
The routine completed successfully. |
CS_FAIL |
The routine failed. |
#include <ospublic.h>
/*
** Local Prototype
*/
CS_RETCODE ex_srv_alt_descfmt PROTOTYPE((
SRV_PROC *sproc,
CS_INT altid,
CS_DATAFMT clfmtp[]
));
/*
** EX_SRV_ALT_DESCFMT
** An example routine to describe the aggregate operator of 2
** compute row columns and the format of each of the two column
** data returned to the client. We will do the sum on the first
** column and average on the second column.
**
** Arguments:
** sproc A pointer to an internal thread control structure.
** altid The id for the compute row in which this compute
** column is contained. The altid is obtained by
** calling srv_alt_header.
** clfmtp A pointer to the array of structures describing
** the format of the compute row column
** data when the client receives it.
**
** Returns:
** CS_SUCCEED If the aggregate operator and the datatype of
** the compute row columns were successfully
** described.
** CS_FAIL An error was detected.
*/
CS_RETCODE ex_srv_alt_descfmt(sproc, altid, clfmtp)
SRV_PROC *sproc;
CS_INT altid;
CS_DATAFMT clfmtp[];
{
/*
** Describe the aggregate operator of the first compute row
** column and the format of the column data.
*/
if ( srv_alt_descfmt(sproc, altid, (CS_INT)1, CS_OP_SUM,
(CS_TINYINT)1, &clfmtp[0]) == CS_FAIL )
{
return(CS_FAIL);
}
/*
** Now do the same for the second column if (srv_alt_descfmt
** (sproc, altid, (CS_INT)2, CS_OP_AVG, (CS_TINYINT)2,
** &clfmtp[1]) == CS_FAIL )
{
return(CS_FAIL);
}
*/
return(CS_SUCCEED);
}
Only applications that mimic Adaptive Server Enterprise’s feature of returning compute row information will need to call srv_alt_descfmt. srv_alt_descfmt is most useful to applications acting as a gateway to an Adaptive Server Enterprise.
srv_alt_descfmt describes a compute row column that the application will send to the client. The application calls it once for each column in the compute row.
The srv_alt_descfmt routine reads from (CS_GET) or sets (CS_SET) the CS_DATAFMT fields listed in the table below. All other fields are undefined for srv_alt_descfmt. (Note that “clfmtp” is a pointer to the structure.
Field |
CS_SET |
CS_GET |
---|---|---|
clfmtp→namelen |
Length of name |
Length of name |
clfmtp→status |
Parameter/column status |
Parameter status |
clfmtp→name |
Parameter/column name |
Parameter name |
clfmtp→datatype |
Remote datatype set here |
Remote datatype retrieved from here |
clfmtp→maxlength |
Maximum length of remote datatype set here |
Maximum length of remote datatype retrieved from here |
clfmtp→format |
Remote datatype format |
Remote datatype formats |
If the format described by clfmtp differs from the application program variable format subsequently described with srv_alt_bind (osfmtp), Open Server automatically converts the data to the clfmtp format description.
To process compute row data, an Open Server application must:
Call srv_alt_header to define a compute row identifier.
Call srv_alt_descfmt 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.
srv_alt_bind, srv_alt_header, srv_alt_xferdata, “CS_DATAFMT structure”