Returns the actual length of the data for a compute column.
DBINT dbadlen (
PDBPROCESS dbproc,
INT computeid,
INT column );
The length, in bytes, of the data for a compute column. When no such column or COMPUTE clause exists, -1 is returned. When the data has a null value, 0 is returned.
This dbadlen returns the length of the data for a compute column. You can get a pointer to the actual data by using dbadata. Calling dbadata after dbnextrow or dbgetrow returns a computeid.
The following program fragment shows how to use dbadlen:
DBPROCESS *dbproc;
char biggest_name[MAXNAME+1];
DBINT namelen;
STATUS rowinfo;
// Put the command into the command buffer.
dbcmd(dbproc, "SELECT name FROM sysobjects");
dbcmd(dbproc, " ORDER BY name");
dbcmd(dbproc, " COMPUTE MAX(name)");
// Send the command to SQL Server and start execution.
dbsqlexec(dbproc);
// Process the command.
dbresults(dbproc);
// Examine each row returned by the command.
while ((rowinfo = dbnextrow(dbproc)) != NO_MORE_ROWS)
{
if (rowinfo == REG_ROW)
printf("Regular row returned.\n");
else
{
// This row is the result of a COMPUTE clause,
// and "rowinfo" is the computeid of this COMPUTE
// clause.
namelen = dbadlen(dbproc, rowinfo, 1);
strncpy(biggest_name,(char *)dbadata(dbproc, rowinfo, 1),
(int)namelen);
// Data pointed to by dbadata() is not null-terminated.
biggest_name[namelen] = '\0';
printf("biggest name = %s\n", biggest_name);
}
}
dbadata | dbgetrow |
dbaltlen | dbnextrow |
dbalttype | dbnumalts |