srv_alt_descfmt

Description

Describe the aggregate operator of a compute row column and the format of the column data returned to the client.

Syntax

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;

Parameters

spp

A pointer to an internal thread control structure.

altid

The unique identifier for the compute row in which this compute column is contained. The altid is defined using srv_alt_header.

item

The column’s column number in the compute row. Compute row column numbers start at 1.

optype

The aggregate operator type of the compute row column. The following table lists the legal operator types:

Table 3-5: Values for optype (srv_alt_descfmt)

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

operand

The select-list column the aggregate is operating on.

clfmtp

A pointer to the CS_DATAFMT structure. This structure describes the format the column data is in when the client receives it.

Returns

Table 3-6: Return values (srv_alt_descfmt)

Returns

To indicate

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

Examples

Example 1

#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);
 }

Usage

See also

srv_alt_bind, srv_alt_header, srv_alt_xferdata, “CS_DATAFMT structure”