See Also: Declaring Variables, Struct
SQLColumnInfo returns the column information for the result set into a array of tSQLColumnInfo structs. If you want to put the results into a grid the column information for example can be used to initialize your grid columns. Always call SQLColumnInfo after a SQLExecute or SQLExecDirect.
Use tSQLExecutor.pkg
Struct tSQLColumnInfo
String sName
Integer iType
Integer iSize
Integer iDigits
Boolean bNullable
End_Struct
sName
The column name.
iType
The column's SQL data type.
iSize
The data size of the column in the table.
iDigits
The number of digits following the decimal separator.
bNullable
Whether the column is nullabe.
The SQLExecutor uses ODBC and returns whatever the SQL Server (or other backend) ODBC driver returns.
In ODBC, the size of a numeric column is the maximum number of digits (before and after the decimal separator) that fit in the column. The digits is the number of decimals. For a Numeric(10.3) the size is 10 and the Digits is 3. A numeric 10.3 can contain 7 before the decimal separator and 3 after. (Note this is the definition in SQL, not in DataFlex !)
Sample:
CREATE TABLE [dbo].[TestBigNumberTable](
[ID] [int] NOT NULL,
[Numeric25_0_Column] [numeric](25, 0) NOT NULL,
[Numeric16_16_Column] [numeric](32, 16) NOT NULL,
[Numeric18_16_Column] [numeric](34, 16) NOT NULL,
SQLExecutor returns this in tSQLColumnInfo as:
SQLColumnInfo: ResultSet: 0 Column: 0, sName=ID, iType=4, iSize=10, , iDigits=0
SQLColumnInfo: ResultSet: 0 Column: 1, sName=Numeric25_0_Column, iType=2, iSize=25, , iDigits=0
SQLColumnInfo: ResultSet: 0 Column: 2, sName=Numeric16_16_Column, iType=2, iSize=32, , iDigits=16
SQLColumnInfo: ResultSet: 0 Column: 3, sName=Numeric18_16_Column, iType=2, iSize=34, , iDigits=16
Use tSQLExecutor.pkg
:
tSQLColumnInfo {variableName}
To declare tSQLColumnInfo variables, use the name of the type (tSQLColumnInfo) followed by the variable name.
tSQLColumnInfo MySQLColumnInfo
See struct variables for more details of instantiating struct types.