Return the actual length of the data for a compute column.
DBINT dbadlen(dbproc, computeid, column) DBPROCESS *dbproc; int computeid; int column;
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.
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.
The number of the column of interest. The first column is number 1.
The length, in bytes, of the data for a particular compute column. If there is no such column or compute clause, dbadlen returns -1. If the data has a null value, dbadlen returns 0.
This routine returns the actual length of the data for a particular compute column.
Use the dbaltlen routine to determine the maximum possible length for the data. Use dbadata to get a pointer to the data.
Here is a program fragment that illustrates the use of dbadlen:
DBPROCESS *dbproc;
char biggest_name[MAXNAME+1];
int namelen;
int 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 Adaptive Server Enterprise 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),
namelen);
/*
** Data pointed to by dbadata() is not
** null-terminated.
*/
biggest_name[namelen] = ’\0’;
printf("biggest name = %s\n",
biggest_name);
}
}
dbadata, dbaltlen, dbalttype, dbgetrow, dbnextrow, dbnumalts