Return the datatype for a regular result column.
int dbcoltype(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.
A token value for the datatype for a particular column.
In a few cases, the token value returned by this routine may not correspond exactly with the column’s server datatype:
SYBVARCHAR is returned as SYBCHAR.
SYBVARBINARY is returned as SYBBINARY.
SYBDATETIMN is returned as SYBDATETIME.
SYBMONEYN is returned as SYBMONEY.
SYBFLTN is returned as SYBFLT8.
SYBINTN is returned as SYBINT1, SYBINT2, or SYBINT4, depending on the actual type of the SYBINTN.
If the column number is not in range, dbcoltype returns -1.
This routine returns the datatype for a regular (that is, non-compute) result column. For a list of server datatypes, see Types.
dbcoltype actually returns an integer token value for the datatype (SYBCHAR, SYBFLT8, and so on). To convert the token value into a readable token string, use dbprtype. See the dbprtype reference page for a list of all token values and their equivalent token strings.
You can use dbvarylen to determine whether a column’s datatype is variable length.
Here is a program fragment that uses dbcoltype:
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 Adaptive Server Enterprise 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, dbvarylen, Types