Skip to content

DF_FIELD_NAME

See Also: Get_Attribute, Set_Attribute, DF_FIELD_NUMBER

The name of a column.

Level

Column

Supported by

All Drivers

Type

String, permanent

Access

Read / Write

Values

A string containing the name of the column.

Remarks

The name of a column, the maximum length and legal characters depend on the back end in use.

In the Embedded Database, column names can be any combination of characters, up to 32 characters long, that starts with a letter and contains no punctuation other than underscore (_).

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.

For All Drivers, this is a permanent attribute that can only be set inside a Structure_Start ... Structure_End operation. For the non-Embedded Database drivers, the permanent value of this attribute can be stored in the intermediate file using the Field_Name keyword.

Examples

Example 1: Show Column Names

Procedure ShowNames Handle hTable
    String sTable sColumn
    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 sColumn
        Showln (Right("    " + String(iColumn), 5)) ": " sColumn
    Loop
End_Procedure

This example retrieves and displays the name of all columns in the table.

Example 2: Add Last Name Column

Procedure AddLastNameColumn Handle hTable
    Integer iColumn

    Open hTable Mode DF_EXCLUSIVE
    Structure_Start hTable

    Move 0 To iColumn
    Create_Field hTable At iColumn
    Set_Attribute DF_FIELD_NAME Of hTable iColumn To "LastName"
    Set_Attribute DF_FIELD_TYPE Of hTable iColumn To DF_ASCII
    Set_Attribute DF_FIELD_LENGTH Of hTable iColumn To 50

    Structure_End hTable
End_Procedure

This example adds a field named LastName, of type ASCII and length 50 to the end (as the last field) of the table.