Returns the datatype for a regular result column.
INT dbcoltype (
PDBPROCESS dbproc,
INT column );
where
A value for the datatype for the particular column. If the column is not in range,
-1 is returned.
Column datatype |
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 a list of SQL Server types, see DB-Library Datatypes. 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, dbcolname, dbdata, dbdatlen, dbnumcols, dbprtype; DB-Library Datatypes