Database Engines:odbc

Which data types are available on the server? Professional

The data types available on the server being supported by an Xbase++ application can be obtained from the DacSession object after a connection to the server is established. This is illustrated with the following code:

cConnect := "<... the connection string ...>" 

oSession := DacSession():new( cConnect ) 

aTypes   := oSession:setProperty( ODBCSSN_ODBC_TO_XPP ) 

ASort( aTypes,,, {|a1,a2| a1[1] < a2[1] } ) 

? "DBMS-type => DDL-type" 
AEval( aTypes, {|a| QOut( a[1], "=>", a[2] ) } ) 

The :setProperty() method returns a two-column array when it receives as parameter the #define constant ODBCSSN_ODBC_TO_XPP contained in ODBCDBE.CH. The array contains in its first column the DBMS-types, as they are exposed by the server, and the second column contains the corresponding DDL-types (refer to Data type mapping for an explanation of DDL-types and DBMS-types).

An example output of the code is shown below. It was created after connecting to MS SQL Server:

DBMS-type => DDL-type 

binary => X 
bit => L 
char => C 
datetime => D 
decimal => N 
float => F 
image => V 
int => I 
nchar => W 
ntext => Q 
numeric => N 
nvarchar => Q 
real => F 
smallint => N 
text => M 
tinyint => N 
uniqueidentifier => C 
varbinary => V 
varchar => M 

A character string containing all DDL-types applicable for a server can be retrieved from a DacSession object in the following way:

? oSession:setProperty( ODBCSSN_DATATYPES  )  // result: CNLDMIFXVWQ 


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.