Skip to content

DF_FIELD_OLD_NUMBER

See Also: Get_Attribute, Set_Attribute

The field number of the field in the previous structure.

Level

Column

Supported by

All Drivers

Type

Numeric, temporary

Access

Read / Write

Values

0 ~ maximum fields allowed in database

Remarks

During structure operations on an existing file, DF_FIELD_OLD_NUMBER specifies which position in the existing file the field occupies. For new fields, DF_FIELD_OLD_NUMBER is 0. This attribute can be used to move data from one field to another during the data restructure.

This is a permanent attribute that can only be set inside a Structure_Start ... Structure_End operation. The DataFlex Pervasive.SQL Driver does not support setting this attribute; however, the other drivers, including the Embedded Database, do support setting this attribute.

Procedure MoveColumn Handle hTable Integer iOld Integer iNew
    String sColumn
    Integer iType
    Integer iLength
    Integer iPrecision

    Open hTable Mode DF_EXCLUSIVE
    Get_Attribute DF_FIELD_NAME Of hTable iOld To sColumn
    Get_Attribute DF_FIELD_TYPE Of hTable iOld To iType

    If (iType <> DF_DATE) ;
        Get_Attribute DF_FIELD_LENGTH Of hTable iOld To iLength

    If (iType = DF_BCD) ;
        Get_Attribute DF_FIELD_PRECISION Of hTable iOld To iPrecision

    Structure_Start hTable
        Delete_Field hTable iOld
        Create_Field hTable At iNew
        Set_Attribute DF_FIELD_NAME Of hTable iNew To sColumn
        Set_Attribute DF_FIELD_TYPE Of hTable iNew To iType

        If (iType <> DF_DATE) ;
            Set_Attribute DF_FIELD_LENGTH Of hTable iNew To iLength

        If (iType = DF_BCD) ;
            Set_Attribute DF_FIELD_PRECISION Of hTable iNew To iPrecision

        Set_Attribute DF_FIELD_OLD_NUMBER Of hTable iNew To iOld
    Structure_End hTable
End_Procedure // MoveColumn

This example moves a column with its contents to another position in the table.