dbbylist

Returns the bylist for a compute row.

Syntax

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

where

dbproc
Is the DBPROCESS structure that is the handle for a particular workstation/ 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.

Example

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, dbadlen, dbaltlen, dbalttype, dbcolname, dbgetrow, dbnextrow, dbresults