dbcollen

Returns the maximum length, in bytes, of the data for a column.

Syntax

DBINT dbcollen (
PDBPROCESS
dbproc,
INT
column );

where

dbproc
Is the DBPROCESS structure that is the handle for a particular workstation/ SQL Server process. It contains all the information that DB-Library uses to manage communications and data between the workstation and SQL Server.
column
Is the number of the column. The first column is number 1. For further information, see "dbadata."

Returns

The maximum length of the data for the particular column. If the column number is not in range, -1 is returned.

Remarks

In the case of variable length data, the maximum length is not necessarily the actual length of the data, but rather the maximum length that the data can be. For the actual data length, use dbdatlen. Call dbcollen after dbresults returns SUCCEED.

Example

The following example shows how to use dbcollen:

DBPROCESS    *dbproc;
int            colnum;
DBINT        column_length;

// Put the command into the command buffer. 
dbcmd(dbproc, "select name, id, type from sysobjects");

// Send the command to SQL Server and begin execution. 
dbsqlexec(dbproc);

// Process the command results. 
dbresults(dbproc);

// Examine the column lengths. 
for (colnum = 1; colnum < 4; colnum+)
{
    column_length = dbcollen(dbproc, colnum);
    printf("column %d, length is %ld.\n", colnum, column_length);
}

See Also

dbcolname, dbcoltype, dbdata, dbdatlen, dbnumcols