Skip to content

DF_FIELD_SQL_COLUMN_NAME

This attribute returns the column name as defined in a SQL database.

Level

Database

Supported by

The DataFlex SQL Drivers (SQL Server, DB2, and ODBC)

Type

String, temporary

Access

Read Only

Values

String

Syntax

Use cli.pkg
Get_Attribute DF_FIELD_SQL_COLUMN_NAME of {tableNumber} {columnNumber} to {StringVariable}

Remarks

DF_FIELD_SQL_COLUMN_NAME returns the name of a column as it is defined in the SQL database. SQL column names can have special characters that are not allowed in DataFlex column names. For example, spaces, accented characters, or special characters like æ.

The DF_FIELD_NAME attribute returns a column name as allowed in DataFlex. Disallowed characters are replaced by underscores.

To retrieve the exact name as defined in SQL, use the DF_FIELD_SQL_COLUMN_NAME attribute. The returned value can be used to compose embedded SQL statements and with SQL filters.

The DF_FIELD_SQL_COLUMN_NAME attribute cannot be set.

Example

The following example shows the DF_FIELD_NAME and DF_FIELD_SQL_COLUMN_NAME for all columns of a table.

Procedure ShowNames Handle hTable
    String sTable
    String sColumnName
    String sSQLColumnName
    Integer iNumColumns iColumn

    Get_Attribute DF_FILE_ROOT_NAME of hTable to sTable
    Showln "The columns in table " sTable " have the following names:"

    Get_Attribute DF_FILE_NUMBER_FIELDS of hTable to iNumColumns
    For iColumn from 1 to iNumColumns
        Get_Attribute DF_FIELD_NAME of hTable iColumn to sColumnName
        Get_Attribute DF_FIELD_SQL_COLUMN_NAME of hTable iColumn to sSQLColumnName
        Showln (SFormat(" DF_FIELD_NAME=%1 DF_FIELD_SQL_COLUMN_NAME=%2", sColumnName, sSQLColumnName))
    Loop
End_Procedure