DF_FIELD_NATIVE_TYPE
The native type of a column.
Level
Column
Supported by
The DataFlex SQL Drivers (SQL Server, DB2, and ODBC), revision 3.0 and higher.
Microsoft SQL Server-specific types are supported in the SQL Server Driver revision 6.0 and higher. See the full list of supported types and type mappings for Microsoft SQL Server here.
IBM DB2-specific types are supported in the IBM DB2 Driver revision 6.0 and higher. See the full list of supported types and type mappings for IBM DB2 here.
Type
Enumeration list (Integer), permanent
Access
Read / Write
Values
- SQL_UNKNOWN_TYPE
- SQL_CHAR
- SQL_NUMERIC
- SQL_DECIMAL
- SQL_INTEGER
- SQL_SMALLINT
- SQL_FLOAT
- SQL_REAL
- SQL_DOUBLE
- SQL_DATETIME
- SQL_VARCHAR
- SQL_TYPE_DATE
- SQL_TYPE_TIME
- SQL_TYPE_TIMESTAMP
- SQL_DATE
- SQL_INTERVAL
- SQL_TIME
- SQL_TIMESTAMP
- SQL_LONGVARCHAR
- SQL_BINARY
- SQL_VARBINARY
- SQL_LONGVARBINARY
- SQL_BIGINT
- SQL_TINYINT
- SQL_BIT
- SQL_WCHAR
- SQL_WVARCHAR
- SQL_WLONGVARCHAR
- SQL_GUID
Microsoft SQL Server-specific Values
- SQL_SS_TIMESTAMPOFFSET
- SQL_SS_TIME2
- SQL_SS_XML
- SQL_SS_VARIANT
- SQL_TYPE_TIMESTAMP2
- SQL_VARCHARMAX
- SQL_WVARCHARMAX
- SQL_VARBINARYMAX
- SQL_TYPE_MONEY
- SQL_TYPE_SMALLMONEY
- SQL_TYPE_SMALLDATETIME
IBM DB2-specific Values
- SQL_CLOB
- SQL_BLOB
- SQL_XML
- SQL_GRAPHIC
- SQL_VARGRAPHIC
- SQL_LONGVARGRAPHIC
- SQL_DBCLOB
Syntax
Use cli.pkg
Get_Attribute DF_FIELD_NATIVE_TYPE of {tableNumber} {columnNumber} to {IntegerVariable}
Set_Attribute DF_FIELD_NATIVE_TYPE of {tableNumber} {columnNumber} to {One of possible Values listed}
For Microsoft SQL-specific Values
Use MSSQLDrv.pkg
Get_Attribute DF_FIELD_NATIVE_TYPE of {tableNumber} {columnNumber} to {IntegerVariable}
Set_Attribute DF_FIELD_NATIVE_TYPE of {tableNumber} {columnNumber} to {One of possible Values listed}
For IBM DB2-specific Values
Use DB2_Drv.pkg
Get_Attribute DF_FIELD_NATIVE_TYPE of {tableNumber} {columnNumber} to {IntegerVariable}
Set_Attribute DF_FIELD_NATIVE_TYPE of {tableNumber} {columnNumber} to {One of possible Values listed}
Remarks
This attribute returns the ID of the column's native type. The DataFlex Database API supports actual types ASCII, Numeric, Date, Text, and Binary. SQL Databases typically support more than these types. The driver will convert a column’s type to one of the supported types and report that in the DF_FIELD_TYPE attribute. The DF_FIELD_NATIVE_TYPE attribute allows more control over a column’s type.
Do not set both DF_FIELD_NATIVE_TYPE and DF_FIELD_TYPE attribute for the same column. If you set DF_FIELD_TYPE, the driver will determine the best fitting DF_FIELD_NATIVE_TYPE. If you set DF_FIELD_NATIVE_TYPE, the driver will determine the best fitting DF_FIELD_TYPE.
This is a permanent attribute that can only be set inside a Structure_Start ... Structure_End operation.
Procedure ChangeCharToVarchar Handle hTable
Integer iNumColumns
Integer iColumn
Integer iNativeType
Structure_Start hTable
Get_Attribute DF_FILE_NUMBER_FIELDS Of hTable To iNumColumns
For iColumn From 1 To iNumColumns
Get_Attribute DF_FIELD_NATIVE_TYPE Of hTable iColumn To iNativeType
If (iNativeType = SQL_CHAR) ;
Set_Attribute DF_FIELD_NATIVE_TYPE Of hTable iColumn To SQL_VARCHAR
Loop
Structure_End hTable
End_Procedure
This example changes all char columns of a table into varchar.