Skip to content

tSQLColumnInfo

See Also: Declaring Variables, Struct

Purpose

The [SQLColumnInfo](../VdfClassRef/WebAndWindows/cBaseSQLExecutor-Function-SQLColumnInfo.md) function returns the column information for the result set into an array of tSQLColumnInfo structs. If you want to put the results into a grid, the column information can be used to initialize your grid columns. Always call SQLColumnInfo after a [SQLExecute](../VdfClassRef/WebAndWindows/cBaseSQLExecutor-Procedure-SQLExecute.md) or [SQLExecDirect](../VdfClassRef/WebAndWindows/cBaseSQLExecutor-Procedure-SQLExecDirect.md).

Type Declaration

Use tSQLExecutor.pkg

Struct tSQLColumnInfo
    String  sName
    Integer iType
    Integer iSize
    Integer iDigits
    Boolean bNullable
End_Struct

Struct Members

  • 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 nullable.

More About Size and Digits

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 represent the number of decimals. For a Numeric(10,3), the size is 10 and the digits are 3. A numeric 10,3 can contain 7 digits 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

Syntax

Use tSQLExecutor.pkg

tSQLColumnInfo {variableName}

Declaring Variables

To declare tSQLColumnInfo variables, use the name of the type (tSQLColumnInfo) followed by the variable name.

tSQLColumnInfo MySQLColumnInfo

See struct variables for more details on instantiating struct types.