Defining the Table Type and Primary Index
The type of a table should be set up through the intermediate file keyword Recnum_Table. This keyword is set to “no” for standard tables and to “yes” for recnum tables. If the keyword is not set, the driver will automatically detect the table type. The automatic detection of table types also depends on the setting of the primary index; this is why they are discussed together.
The primary index of a table should be set up through the intermediate file by using the Primary_Index keyword. Note that the Primary_Index keyword is used to define the identifier of both RECNUM and standard tables. You should set the keyword to the number of the unique index. If the primary index is not set, the driver will automatically detect a primary index.
Automatically Detecting Table Type and Primary Index
The automatic detection works in the order defined below:
-
If the primary index is set to 0 (zero), the table is assumed to be a recnum table. The record identity column is assumed to be the first column of the table and is automatically hidden. This happens regardless of the table type setting in the intermediate file.
-
If the table type is not set and the primary index is not set or is set to a non-zero value, the driver will look for a column named “recnum” or “dfrecnum.” If such a column exists, the table is assumed to be a recnum table, and the column is the record identifier. In case the column is named “recnum” and the primary index keyword was not set, it will automatically be hidden. This behavior ensures that driver version 4 can open tables created with previous versions of the driver.
-
If both table type and primary index are not set, and the recnum columns described above are not present, the driver will query if a primary key has been defined on the table. If a primary key is defined, its associated index will be made the primary index. If there is no associated index, one will be created on the DataFlex side.
-
If no primary key exists, the driver will search for a column with the identity attribute. If such a column exists and it is present as the single segment in an index, that index is made the primary index.
-
If none of the above applies, the driver will select the first index with the least number of segments as the primary index.
After detecting the primary index, the table type depends on the contents of the index. If the index contains a single numeric column with no decimal places, the table is assumed to be a recnum table. All other indexes will result in a standard table.
The logic described above can be influenced by setting driver configuration keywords Default_Record_Identity_Hiding and Default_Map_To_RECNUM. Setting the Default_Record_Identity_Hiding keyword to a non-zero value will ensure the record identifiers of all recnum tables are hidden. Setting the Default_Map_To_RECNUM keyword to zero will ensure that tables with a primary index that contains a single numeric column are not interpreted as recnum tables.
See Also
See the appendix on configuration files for more information on configuration files.