Skip to content

DF_FILE_GET_RID_AFTER_CREATE

Indicates whether the value of the record identity column of a recnum table is filled after creating a new record.

Level

Table

Supported by

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

Type

Boolean, permanent/temporary

Access

Read / Write

Values

  • True
  • False

Syntax

Use cli.pkg
Get_Attribute DF_FILE_GET_RID_AFTER_CREATE of {tableNumber} to {BooleanVariable}
Set_Attribute DF_FILE_GET_RID_AFTER_CREATE of {tableNumber} to {True|False}

Remarks

When set to true, after records are created in a table, the assigned record identity is moved to the record buffer used by DataFlex. Setting this attribute to false will switch off moving the new identity to the record buffer. This eliminates a Client/Server communication roundtrip, thus speeding up performance when creating records.

For the DataFlex SQL Driver, the way the record identity is moved to the buffer depends on the setting of the DF_FILE_GENERATE_RECORD_ID_METHOD attribute. If that attribute is set to RIM_IDENTITY_COLUMN, the Ident_Current function of SQL Server will be used (@@IDENTITY in pre SQL Server 2000 versions).

For the DB2 Driver, the way the record identity is moved to the buffer depends on the setting of the DF_FILE_GENERATE_RECORD_ID_METHOD attribute. If that attribute is set to RIM_IDENTITY_COLUMN, the IDENTITY_VAL_LOCAL function of DB2 will be used. When the DF_FILE_GENERATE_RECORD_ID_METHOD attribute is set to RIM_DISPENSER_TABLE, the record identity value will be selected from the dispenser table.

For all DataFlex SQL Drivers, the way the record identity is moved to the buffer when the DF_FILE_GENERATE_RECORD_ID_METHOD attribute is set to RIM_NONE or RIM_EXTERNAL is the same; the maximum value of the record identity column is used.

Be aware that setting this attribute to false can result in unwanted or erroneous behavior. Switching off the move behavior can speed up bulk creation of records. Normally, you will only use this attribute from within the program logic where it will be used in massive record creations. In such cases, it will be switched off, then the records are created, after which the attribute is switched back ON.

This attribute can be set both inside and outside of a Structure_Start ... Structure_End operation. The value of this attribute is stored in the intermediate file using the intermediate file keyword Get_RID_After_Create.

Example Procedures

CopyRecord

Procedure CopyRecord Handle hSource Handle hDest
    Integer iNumColumns
    Integer iColumn
    String sValue

    Get_Attribute DF_FILE_NUMBER_FIELDS Of hSource To iNumColumns
    Begin_Transaction
    Clear hDest
    For iColumn From 1 To iNumColumns
        Get_Field_value hSource iColumn To sValue
        Set_Field_Value hDest iColumn To sValue
    Loop
    SaveRecord hDest
    End_Transaction
End_Procedure // CopyRecord

CopyTable

Procedure CopyTable Handle hSource Handle hDest
    Integer iIndex
    Boolean bFound
    Boolean bOrgGetRIDAfterCreate

    //*** Primary index attribute not supported by Embedded Database
    //*** and Pervasive.SQL, avoid errors.
    Set_Attribute DF_REPORT_UNSUPPORTED_ATTRIBUTES To False
    Get_Attribute DF_FILE_PRIMARY_INDEX Of hSource To iIndex
    Set_Attribute DF_REPORT_UNSUPPORTED_ATTRIBUTES To False

    //*** Reset DF_FILE_GET_RID_AFTER_CREATE
    Get_Attribute DF_FILE_GET_RID_AFTER_CREATE Of hDest To bOrgGetRIDAfterCreate
    Set_Attribute DF_FILE_GET_RID_AFTER_CREATE Of hDest To False

    //*** Loop through all records from source
    Clear hSource
    Repeat
        vFind hSource iIndex Gt
        Move (Found) To bFound
        If (bFound) ;
            Send CopyRecord hSource hDest
    Until (Not(bFound))

    //*** Reset DF_FILE_GET_RID_AFTER_CREATE
    Set_Attribute DF_FILE_GET_RID_AFTER_CREATE Of hDest To bOrgGetRIDAfterCreate
End_Procedure // CopyTable

The two procedures above copy all data from one table to another. The DF_FILE_GET_RID_AFTER_CREATE attribute of the destination table (the table where records are created) is switched off before the copy process starts and reset to its original value after the copy process finishes.