dbalttype

Returns the datatype for a compute column.

Syntax

INT dbalttype (
PDBPROCESS
dbproc,
INT
computeid,
INT
column );

where

dbproc
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.
computeid
The ID that identifies the COMPUTE clause. A SELECT statement can have multiple COMPUTE clauses, which can have varying numbers of aggregate operators and aggregate targets. The computeid is returned by dbnextrow or dbgetrow.
column
The number of the column. The first column is number 1.

Returns

The type of the data for the particular column in the compute. The types are defined as follows:

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

Call dbalttype only after dbnextrow or dbgetrow returns a computeid.

If either the computeid or column is invalid, -1 is returned.

Example

In the following SELECT, calling dbalttype(dbproc, 1, 1) returns the type for SQLINT4 since counts are of SQLINT4 type.

select dept, name from employee
order by dept, name
compute count(name) by dept

To convert the type to a readable string, use dbprtype.

See Also

dbadata, dbadlen, dbaltlen, dbgetrow, dbnextrow, dbnumalts, dbprtype; DB-Library Datatypes