usumfld

Supplies Uniface with the result of an aggregate computation in the Select mode 4 connector request.

void usumfld(uc, result, length, pack)

struct uctrl *uc;

unsigned char *result;

short length;

short pack;

Parameters

  • uc—address of the current control block.
  • result—pointer to the result value.
  • length—length of the result value pointed to by result.
  • pack—connector-level packing code of the result value.

Return Values

Not applicable.

Description

Supplies Uniface with the result of an aggregate computation in the Select mode 4 connector request. usumfld must be called once for every entry in the uordlst structure. Calls to usumfld must be in the same order as the entries appear in the uordlst structure.

The following example assumes the results of the calculation of aggregates is already known and can be accessed through an SQL descriptor area (SQLDA). This example is based on the DEC Rdb API, the implementation of the data structures used can differ for other APIs.

The following function is called in the example:

MapDBMSToPackingCode—Fetch the next record from the specified (open) cursor and update the values in SQLDA.

The DrvAdminType data type is created for this example, it holds the PRA in its PRA field. Such a structure would usually be stored in the connector workspace (uctrl->udrv).

ReturnAggregatesToUniface (struct uctrl *ControlBlock,
SQLDA *DescriptorArea )
{
SQLVAR *SQLVar;
int i;
long LengthToReturn;
short TypeToReturn;
for ( SQLVar = DescriptorArea->sqlvar, i = 0;
i < DescriptorArea->sqld;/* sqld gives the number */
SQLVar++, i++ ) /* of sqlvar elements present.*/
{
if ( SQLVar->sqlind == -1 ) /* Indicates a NULL value. */
{
LengthToReturn = 0; /* This way a NULL value is */
TypeToReturn = pC; /* reported to UNIFACE. */
}
else
{
LengthToReturn = SQLVar->sqllen;
TypeToReturn = MapDBMSTypeToPackingCode ( SQLVar->sqltype,
LengthToReturn );
}
usumfld (ControlBlock,
(unsigned char *)SQLVar->sqldata,
LengthToReturn,
TypeToReturn );
}
}