Return the length of the data in a regular result column.
DBINT dbdatlen(dbproc, column) DBPROCESS *dbproc; 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 number of the column of interest. The first column is number 1.
The length, in bytes, of the data that would be returned for the particular column. If the data has a null value, dbdatlen returns 0. If the column number is not in range, dbdatlen returns -1.
This routine returns the length, in bytes, of data that would be returned by a select against a regular (that is, non-compute) result column. In most cases, this is the actual length of data for the column. For text and image columns, however, the integer returned by dbdatlen can be less than the actual length of data for the column. This is because the server global variable @@textsize limits the amount of text or image data returned by a select.
Use the dbcollen routine to determine the maximum possible length for the data. Use dbdata to get a pointer to the data itself.
Here is a small program fragment that uses dbdatlen:
DBPROCESS *dbproc;
DBINT row_number = 0;
DBINT data_length;
* Put the command into the command buffer */
dbcmd(dbproc, "select name from sysobjects");
/*
** Send the command to Adaptive Server Enterprise and begin
** execution
*/
dbsqlexec(dbproc);
/* Process the command results */
dbresults(dbproc);
/* Examine the data lengths of each row */
while (dbnextrow(dbproc) != NO_MORE_ROWS)
{
row_number++;
data_length = dbdatlen(dbproc, 1);
printf("row %ld, data length is %ld.\n",
row_number, data_length);
}