dbbylist

Returns the bylist for a compute row.

Syntax

LPCBYTE dbbylist (
PDBPROCESS
dbproc,
INT
computeid,
LPINT
size );

Arguments
dbproc
Is the DBPROCESS structure that is the handle for a particular workstation/ Microsoft® SQL Server™ process. It contains all the information that DB-Library uses to manage communications and data between the workstation and SQL Server.
computeid
Is the ID that identifies the COMPUTE clause. A SELECT statement can have multiple COMPUTE clauses, which can have varying numbers of aggregate operators and targets. The computeid is returned by dbnextrow or dbgetrow.
size
Is a pointer to an integer which dbbylist sets to the number of elements in the bylist.
Returns

A pointer to an array of BYTES containing the numbers of the columns that compose the bylist for the specified compute. The names of the columns are available by calling dbcolname. If the computeid is out of range, NULL is returned.

The size of the array is returned in the size parameter. A size of 0 indicates that either this particular compute has no bylist or the computeid is out of range.

Remarks

A 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 row aggregate is applied to each subgroup, generating a compute row for each subgroup.

Call this function after dbresults has returned SUCCEED.

Examples

Assume the following command has been executed:

SELECT dept, name, year, sales FROM employee
ORDER BY dept, name, year
COMPUTE COUNT(name) BY dept,name

  

The call dbbylist(dbproc, 1, &size) sets size to 2 because there are two items in the bylist. It returns a pointer to an array of 2 BYTES, which contain the values 1 and 2, indicating that the bylist is composed of columns 1 and 2 from the select list.

See Also
dbadata dbcolname
dbadlen dbgetrow
dbaltlen dbnextrow
dbalttype dbresults

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.