COUNT Function (Record)

Counts the number of records in a C/SIDE table.

Number := Record.COUNT

Parameters

  • Record
    Type: Record

    Refers to the table to be counted.

Property Value/Return Value

Type: Integer

The number of records in the table.

Remarks

This function returns the number of records that meet the conditions of any filters associated with the records. If no filters are set, the function shows the total number of records in the table.

Note

The COUNT function does not lock the table before retrieving the number of records in the table. This means that the function reads both uncommitted and committed data, which could cause the number of records that are returned to be inaccurate. To ensure that the count is accurate, use the LOCKTABLE Function (Record) before you use the COUNT function.

Example

This example requires that you create the following variables.

Variable name DataType Subtype

CustomerCount

Integer

 

CustomerRec

Record

Customer

CustomerCount := CustomerRec.COUNT;
// This statement assigns the number of records in the Customer table
// to the CustomerCount variable. This statement is the same as:
CustomerCount := 0;
IF CustomerRec.FIND('-') THEN
  REPEAT
    CustomerCount := CustomerCount + 1;
  UNTIL CustomerRec.NEXT = 0;

Retrieving the count by using the first statement in the example is much faster because only one command to the Database Management System (DMBS) is needed.

See Also

Reference

Record Data Type