dbcollen

DB Library for C

DB Library for C

dbcollen

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

Syntax

DBINT dbcollen (
PDBPROCESS
dbproc,
INT
column );

Arguments

dbproc

Is the DBPROCESS structure that is the handle for a particular workstation or Microsoft® SQL Server™ 2000 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.

Examples

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

dbdatlen

dbcoltype

dbnumcols

dbdata