Skip to content

DF_FILE_RECORDS_USED

See Also: Get_Attribute, Set_Attribute, DF_FILE_MAX_RECORDS

The number of records that exist in the table.

Level

Table

Supported by

All Drivers

Type

Numeric, permanent

Access

Read Only

Values

  • 0 ~ maximum number of records allowed in the database

Remarks

This attribute represents the number of records currently in the table, not including deleted records. This attribute cannot be set directly. It is set indirectly by adding and/or removing records.

In SQL back ends, the only way to get the number of records in a table is to count them. Depending on the back end, this can be an expensive operation. Be careful when using this attribute.

Procedure ShowRecordsUsed
    Handle hTable
    String sTable
    Integer iNumRecords
    Number nTotalRecords

    Move 0 To hTable
    Move 0 To nTotalRecords

    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_RECORDS_USED Of hTable To iNumRecords
            Showln sTable " -- " iNumRecords
            Add iNumRecords To nTotalRecords
            Close hTable
        End
    Until (hTable = 0)

    Showln "Total -- " nTotalRecords
End_Procedure // ShowRecordsUsed

The sample procedure above shows the number of records in use for every table in the filelist. At the end, it shows the total number of records.