Skip to content

DF_FILE_GENERATE_RECORD_ID_METHOD

Indicates how the record identity column of a recnum table is filled.

Level

Table

Supported by

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

Type

Enumeration list, permanent

Access

Read / Write

Values

  • RIM_NONE
  • RIM_IDENTITY_COLUMN
  • RIM_EXTERNAL
  • RIM_DISPENSER_TABLE

Syntax

Use cli.pkg
Get_Attribute DF_FILE_GENERATE_RECORD_ID_METHOD of {tableNumber} to {IntegerVariable}

Set_Attribute DF_FILE_GENERATE_RECORD_ID_METHOD of {tableNumber} to {RIM_NONE|RIM_IDENTITY_COLUMN|RIM_EXTERNAL|RIM_DISPENSER_TABLE}

Remarks

The Generate_Record_ID_Method setting indicates how the record identity column is filled. There are four possible values:

Value Meaning
RIM_NONE Record identifiers are not generated by the back-end. Record identity values must be filled by giving the columns an explicit value in the application. When a new record is created, the value in the record identifier column is passed to the back-end.
RIM_IDENTITY_COLUMN The record identifier is filled by the back-end using the features the server provides for this (identity columns). When a new record is created, the value in the record identifier column is not passed to the back-end. This value is only applicable to the SQL Server and DB2 Drivers.
RIM_EXTERNAL The record identifier is generated by the back-end but in some other way than using identity columns. For example: one could use triggers. When a new record is created, the value in the record identifier column is not passed to the back-end.
RIM_DISPENSER_TABLE The record identifier value is dispensed from a table that keeps track of the next available record identity value. The dispenser logic is enforced using triggers when records are inserted. When a new record is created, the value in the record identifier column is not passed to the back-end. When a table is opened, a check will be done to see if the triggers, the dispenser table, and the record in the dispenser table for the table being opened exist. If one (or more) of these is missing, it will automatically be created. This value is only applicable to the DB2 Driver.

This attribute can only be set inside of a Structure_Start ... Structure_End operation. The value of this attribute is stored in the intermediate file using the intermediate file keyword Generate_Record_ID_Method.

Setting the attribute to RIM_IDENTITY for a table accessed through the SQL Server or DB2 Driver will ensure the record identity column is created with the identity attribute set. This means the column is automatically filled by the back end.

Example

Procedure CreateTable
    Handle hTable
    Handle hoWorkspace
    String sPath
    String sOrigFolder
    Integer iColumn
    Integer iIndex

    // Make sure int file comes in first folder of datapath by making that folder current
    Get phoWorkspace Of ghoApplication To hoWorkspace
    Get psDataPath Of hoWorkspace To sPath
    Get PathAtIndex Of hoWorkspace sPath 1 To sPath
    Get_Current_Directory To sOrigFolder
    Set_Directory sPath

    // Create a SQL Server table to store clock in/out times of employees
    Move 0 To hTable
    Structure_Start hTable "MSSQLDRV"
    Set_Attribute DF_FILE_PHYSICAL_NAME Of hTable To "RIMSample.int"
    Set_Attribute DF_FILE_RECNUM_TABLE Of hTable To True
    Set_Attribute DF_FILE_LOGIN Of hTable To "SERVER=(local);Trusted_Connection=yes;DATABASE=Northwind"
    Set_Attribute DF_FILE_TABLE_NAME Of hTable To "RIMSample"
    Set_Attribute DF_FILE_GENERATE_RECORD_ID_METHOD Of hTable To RIM_IDENTITY_COLUMN
    Set_Attribute DF_FILE_PRIMARY_INDEX Of hTable To 0

    Create_Field hTable At iColumn
    Set_Attribute DF_FIELD_NAME Of hTable iColumn To "ID"
    Set_Attribute DF_FIELD_TYPE Of hTable iColumn To DF_BCD
    Set_Attribute DF_FIELD_LENGTH Of hTable iColumn To 4

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

    Move 0 To iColumn
    Create_Field hTable At iColumn
    Set_Attribute DF_FIELD_NAME Of hTable iColumn To "Comment"
    Set_Attribute DF_FIELD_TYPE Of hTable iColumn To DF_TEXT
    Set_Attribute DF_FIELD_LENGTH Of hTable iColumn To (5 * (2^20))

    Move 0 To iIndex
    Create_Index hTable At iIndex
    Set_Attribute DF_INDEX_NUMBER_SEGMENTS Of hTable iIndex To 1
    Set_Attribute DF_INDEX_SEGMENT_FIELD Of hTable iIndex 1 To 1
    Set_Attribute DF_INDEX_NAME Of hTable iIndex To "RimSample001"
    Structure_End hTable

    // Reset current working folder to original value
    Set_Directory sOrigFolder

    // Add to filelist and generate fd
    Move 0 To hTable
    Get_Attribute DF_FILE_NEXT_EMPTY Of hTable To hTable
    If (hTable > 0) Begin
        Set_Attribute DF_FILE_ROOT_NAME Of hTable To "MSSQLDRV:RIMSample"
        Set_Attribute DF_FILE_DISPLAY_NAME Of hTable To "RIM sample table"
        Set_Attribute DF_FILE_LOGICAL_NAME Of hTable To "RIMSamp"
        Open hTable
        Get psDDSRCPath Of hoWorkspace To sPath
        Get PathAtIndex Of hoWorkspace sPath 1 To sPath
        If (Right(sPath, 1) <> Sysconf(Sysconf_Dir_Separator)) ;
            Move (sPath - Sysconf(Sysconf_Dir_Separator)) To sPath
        Move (sPath - "RIMSamp.fd") To sPath
        Output_Aux_File DF_AUX_FILE_FD For hTable To sPath
        Close hTable
    End
End_Procedure // CreateTable

This example creates a SQL Server recnum table with a hidden record identity (primary_index = 0) column. Hidden record identity columns are called “RECNUM”. The column has its DF_FILE_GENERATE_RECORD_ID_METHOD set to RIM_IDENTITY_COLUMN, so the identity column has the SQL Server identity attribute set.