Returns the data type for a regular result column.
INT dbcoltype (
PDBPROCESS dbproc,
INT column );
A value for the data type for the particular column. If the column is not in range,
-1 is returned.
Column data type | Returned constant |
---|---|
char | SQLCHAR |
varchar | SQLCHAR |
binary | SQLBINARY |
varbinary | SQLBINARY |
tinyint | SQLINT1 |
smallint | SQLINT2 |
int | SQLINT4 |
real | SQLFLT4 |
float | SQLFLT8 |
smallmoney | SQLMONEY4 |
money | SQLMONEY |
decimal | SQLDECIMAL |
numeric | SQLNUMERIC |
smalldatetime | SQLDATETIM4 |
datetime | SQLDATETIME |
image | SQLIMAGE |
text | SQLTEXT |
The dbcoltype function returns an integer value for the type. Use dbprtype to convert the type value into a readable string. For more information about a list of SQL Server types, see DB-Library for C Data Types. Call dbcoltype after dbresults returns SUCCEED.
This function cannot determine whether a column can take null values.
This example shows how to use dbcoltype and dbprtype:
DBPROCESS *dbproc;
int colnum;
int coltype;
// 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 types.
for (colnum = 1; colnum < 4; colnum++)
{
coltype = dbcoltype(dbproc, colnum);
printf("column %d, type is %s.\n", colnum, dbprtype(coltype));
}
dbcollen | DB-Library for C Data Types |
dbcolname | dbnumcols |
dbdata | dbprtype |
dbdatlen |