dbadata

Description

Return a pointer to the data for a compute column.

Syntax

BYTE *dbadata(dbproc, computeid, colnum)
 
DBPROCESS    *dbproc;
int                       computeid;
int                       colnum;

Parameters

dbproc

A pointer to the DBPROCESS structure that provides the connection for a particular front-end/server process. It contains all the information that DB-Library uses to manage communications and data between the front end and server.

computeid

The ID that identifies the particular compute row of interest. A SQL select statement may have multiple compute clauses, each of which returns a separate compute row. The computeid corresponding to the first compute clause in a select is 1. The computeid is returned by dbnextrow or dbgetrow.

colnum

The number of the column of interest. The first column returned is number 1. Note that the order in which compute columns are returned is determined by the order of the corresponding columns in the select list, not by the order in which the compute columns were originally specified. For example, in the following query the result of “sum(price)” is referenced by giving colnum a value of 1, not 2:

select price, advance from titles 
compute sum(advance), sum(price) 

The relative order of compute columns in the select list, rather than their absolute position, determines the value of colnum. For instance, given the following variation of the previous select:

select title_id, price, advance from titles 
compute sum(advance), sum(price) 

the colnum for “sum(price)” still has a value of 1 and not 2, because the “title_id” column in the select list is not a compute column and therefore is ignored when determining the compute column’s number.

Returns

A BYTE pointer to the data for a particular column in a particular compute. Be sure to cast this pointer into the proper type. A BYTE pointer to NULL is returned if there is no such column or compute or if the data has a null value.

DB-Library allocates and frees the data space that the BYTE pointer points to. Do not overwrite this space.

Usage

See also

dbadlen, dbaltbind, dbaltlen, dbalttype, dbgetrow, dbnextrow, dbnumalts