SQL_GET_COL_ATTRIBUTE

Applies to: ORAFlex SQLFlex MYSQLFlex PGFlex DB2Flex

This command is used to get specific column information from the columns in a result set of an SQL statement. By passing one of the supported attributes below, the command will return the desired information. Note that some attributes only work with specific drivers. See the list below for more information.

Supported attributes are:

SIZE

The maximum length of the column

DATA_LENGTH

Length of data currently in the column

DECIMALS

If numeric, shows number of decimal places

LABEL

Returns the column name in ORAFlex and MySQLFlex

COLUMN_NAME

Returns the name of the column

TABLE_NAME

Returns the name of the table (MySQLFlex only)

SQLTYPE

Returns the number representing the SQL data type

NULLABLE

Returns true if null is allowed, false otherwise (doesn’t work in PostgreSQL)

DFTYPE

Dataflex type column is mapped to

Syntax

SQL_GET_COL_ATTRIBUTE of {columnNumber} {attribute} to {variable}

Parameter

Description

columnNumber

The number of the column that is being examined

attribute

The attribute being checked (see list)

variable

Variable to hold the attribute value

Example

String sFirstName sLastName sColumn1Name sColumn2Name

Open Customer

SQL_SET_STMT to "SELECT * FROM CUSTOMER WHERE STATUS = 'Active' "
SQL_PREPARE_STMT
SQL_EXECUTE_STMT
SQL_FETCH_NEXT_ROW into sFirstName sLastName
If (Found) Begin
    SQL_GET_COL_ATTRIBUTE of 1 COLUMN_NAME to sColumn1Name
    SQL_GET_COL_ATTRIBUTE of 2 COLUMN_NAME to sColumn2Name
    Showln (sColumn1Name + " = " + sFirstName)
    Showln (sColumn2Name + " = " + sLastName)
End