1 Version 4.0 -- 5/1/89 dbdata
______________________________________________________________________
NAME: dbdata
FUNCTION:
Return a pointer to the data in a regular result column.
SYNTAX:
BYTE *dbdata(dbproc, column)
DBPROCESS *dbproc;
int column;
COMMENTS:
dbdata Version 4.0 -- 5/1/89 2
______________________________________________________________________
o This routine returns a pointer to the data in a regular (i.e.,
non-compute) result column. The data is not null-terminated.
You can use dbdatlen() to get the length of the data.
o Here's a small program fragment that uses dbdata():
DBPROCESS *dbproc;
DBINT row_number = 0;
DBINT object_id;
/* put the command into the command buffer */
dbcmd(dbproc, "select id from sysobjects");
/* send the command to SQL Server and begin execution */
dbsqlexec(dbproc);
/* process the command results */
3 Version 4.0 -- 5/1/89 dbdata
______________________________________________________________________
dbresults(dbproc);
/* examine the data in each row */
while (dbnextrow(dbproc) != NO_MORE_ROWS)
{
row_number++;
object_id = *((DBINT *)dbdata(dbproc, 1));
printf("row %ld, object id is %ld.\n", row_number,
object_id);
}
o Do not add a null terminator to string data until you've copied
it from the DBPROCESS with a routine such as strncpy(). For
example:
dbdata Version 4.0 -- 5/1/89 4
______________________________________________________________________
char objname[40]
...
strncpy(objname, (char *)dbdata(dbproc,2), (int)dbdatlen(dbproc,2))
objname[dbdatlen(dbproc,2] = '\0'
o The function dbbind() will automatically bind result data to
your program variables. It does a copy of the data, but is
often easier to use than dbdata(). Furthermore, it includes a
convenient type conversion capability. By means of this capa-
bility, the application can, among other things, easily add a
null terminator to a result string or convert money and date-
time data to printable strings.
PARAMETERS:
dbproc - A pointer to the DBPROCESS structure that provides the
connection for a particular front-end/SQL Server process. It
5 Version 4.0 -- 5/1/89 dbdata
______________________________________________________________________
contains all the information that DB-Library uses to manage
communications and data between the front end and SQL Server.
column - The number of the column of interest. The first column
is number 1.
RETURNS:
A BYTE pointer to the data for the particular column of interest.
Be sure to cast this pointer into the proper type. A NULL BYTE
pointer is returned if there is no such column or if the data has
a null value. To make sure that the data is really a null value,
you should always check for a return of 0 from dbdatlen().
SEE ALSO:
dbbind, dbcollen, dbcolname, dbcoltype, dbdatlen, dbnumcols