DF_FILE_RECNUM_TABLE

See Also: DF_FILE_PRIMARY_INDEX, DF_FILE_RECORD_IDENTITY

 

Specifies if the table contains a Recnum column.

Level

Table

Supported by

All Drivers

Type

Boolean, permanent

Access

Read / Write for the DataFlex SQL Drivers (SQL Server, DB2 and ODBC)

Read Only for DataFlex and Pervasive.SQL

For other drivers, refer to the driver's documentation

Values

True, False

Remarks

The DF_FILE_RECNUM_TABLE attribute determines if Recnum is used to define a table's record identity. Typically this attribute is used to determine if the Recnum column can be used for a table.

When DF_FILE_RECUM_TABLE is true, records in the table are identified by a single numeric column. This may be a logical or physical column. In either case the table will have a column with number 0 that is called recnum. This column can be accessed via Table.Recnum. A Recnum column is treated in a special way. If a value is moved to the recnum column, the buffer is made inactive (the DF_FILE_STATUS attribute is set to DF_FILE_INACTIVE). If a buffer is inactive a save operation on that buffer will create a new record.

When DF_FILE_RECNUM_TABLE is false, records in the table are identified by one or more columns of any type. The identifying columns are defined by setting the DF_FILE_PRIMARY_INDEX attribute.

A recnum table’s column numbers start at 0 (zero) where a standard table’s column numbers start at 1. Attempting to access column 0 (zero) of a standard table will result in an error message (DFERR_FIELD_NUMBER_RANGE).

Note that this attribute determines how the table handles unique identities. It does not determine whether the programming interface will use a Recnum or RowId style programming interface. All table types can and should be accessed using the RowId programming interface. If the RowId programming interface is used, you will not need to know if Recnum is supported, hence, you should rarely need to use this attribute.

This attribute can only be set inside a Structure_Start ... Structure_End operation. The DataFlex SQL Drivers store the value of the attribute in the intermediate file under the Recnum_Table keyword.

The Embedded Database only supports recnum tables, in other words, the value of DF_FILE_RECNUM_TABLE is always true for an Embedded Database table.

The DataFlex Pervasive.SQL Driver only supports recnum tables, in other words, the value of DF_FILE_RECNUM_TABLE is always true for a Pervasive.SQL table.

The DataFlex SQL Drivers support both recnum and standard tables, starting at version 4. Older versions of these drivers only support recnum tables.

Procedure ShowRecnumTables

    Handle hTable

    String sTable

    Boolean bRecnumTable

 

    Move 0 To hTable

    Repeat

        Get_Attribute DF_FILE_NEXT_USED Of hTable To hTable

        If (hTable > 0) Begin

            Open hTable

            Get_Attribute DF_FILE_LOGICAL_NAME Of hTable To sTable

            Get_Attribute DF_FILE_RECNUM_TABLE Of hTable To bRecnumTable

            Showln sTable " -- " (If(bRecnumTable, "RECNUM", "STANDARD")) " table"

            Close hTable

        End

    Until (hTable = 0)

End_Procedure

The sample procedure above shows all tables in the filelist and of every table it shows if it is recnum or a standard table.

Procedure ShowRecord Handle hTable

    Boolean bRecnumTable

    Integer iNumColumns iColumn iStart

    String sValue

 

    Get_Attribute DF_FILE_RECNUM_TABLE Of hTable To bRecnumTable

    If (bRecnumTable) ;

        Move 0 To iStart

    Else ;

        Move 1 To iStart

 

    Get_Attribute DF_FILE_NUMBER_FIELDS Of hTable To iNumColumns

    For iColumn From iStart To iNumColumns

        Get_Field_Value hTable iColumn To sValue

        If (iColumn > iStart) ;

            Show ", "

        Show (Trim(sValue))

    Loop

    Showln

End_Procedure

The sample procedure above shows the contents of a record of a given table. If this is a recnum table it shows the value of the recnum column.

Procedure CreateClockTable

    Handle hTable hoWorkspace

    String sPath sOrigFolder

    Integer iColumn 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 "Clock.int"

        Set_Attribute DF_FILE_RECNUM_TABLE Of hTable To False

        Set_Attribute DF_FILE_LOGIN Of hTable To ;

            "SERVER=(local);Trusted_Connection=yes;DATABASE=Northwind"

        Set_Attribute DF_FILE_TABLE_NAME Of hTable To "Clock"

        Set_Attribute DF_FILE_USE_DUMMY_ZERO_DATE Of hTable To True

 

        Create_Field hTable At iColumn

        Set_Attribute DF_FIELD_NAME Of hTable iColumn To "EmployeeID"

        Set_Attribute DF_FIELD_TYPE Of hTable iColumn To DF_BCD

        Set_Attribute DF_FIELD_LENGTH Of hTable iColumn To 10

        Set_Attribute DF_FIELD_NATIVE_TYPE Of hTable iColumn To SQL_INTEGER

 

        Move 0 To iColumn

        Create_Field hTable At iColumn

        Set_Attribute DF_FIELD_NAME Of hTable iColumn To "ClockInTime"

        Set_Attribute DF_FIELD_TYPE Of hTable iColumn To DF_DATE

 

        Move 0 To iColumn

        Create_Field hTable At iColumn

        Set_Attribute DF_FIELD_NAME Of hTable iColumn To "ClockOutTime"

        Set_Attribute DF_FIELD_TYPE Of hTable iColumn To DF_DATE

 

        Move 0 To iIndex

        Create_Index hTable At iIndex

        Set_Attribute DF_INDEX_NUMBER_SEGMENTS Of hTable iIndex To 3

        Set_Attribute DF_INDEX_SEGMENT_FIELD Of hTable iIndex 1 To 1

        Set_Attribute DF_INDEX_SEGMENT_FIELD Of hTable iIndex 2 To 2

        Set_Attribute DF_INDEX_SEGMENT_DIRECTION Of hTable iIndex 2 To DF_DESCENDING

        Set_Attribute DF_INDEX_SEGMENT_FIELD Of hTable iIndex 3 To 3

        Set_Attribute DF_FILE_PRIMARY_INDEX Of hTable To iIndex

        Set_Attribute DF_INDEX_NAME Of hTable iIndex To "ClockPK"

    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:Clock"

        Set_Attribute DF_FILE_DISPLAY_NAME Of hTable To "Clock sample table"

        Set_Attribute DF_FILE_LOGICAL_NAME Of hTable To "Clock"

 

        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 - "Clock.fd") To sPath

        Output_Aux_File DF_AUX_FILE_FD For hTable To sPath

        Close hTable

    End

End_Procedure

The sample procedure above creates a standard table called Clock with one unique index that is set to be the primary index.