User Tools

Site Tools


records_return_number_of_rows_in_data_set_.htm
Navigation:  Language Reference > 13 - Built-in Functions >====== RECORDS (return number of rows in data set) ====== Previous pageReturn to chapter overviewNext page

RECORDS( entity )

blk2blue.jpg

RECORDS Returns the number of records.
entity The label of a QUEUE, VIEW, FILE, KEY, or INDEX declaration.

The RECORDS procedure returns a LONG integer containing the number of entries in the entity.

FILE Usage

black.jpg

The RECORDS procedure returns the number of records in a FILE, KEY, or INDEX. Since the OPT attribute of a KEY or INDEX excludes “null” entries, RECORDS may return a smaller number for the KEY or INDEX than the FILE.

QUEUE Usage

black.jpg

The RECORDS procedure returns a LONG integer containing the number of entries in the QUEUE.

VIEW Usage

black.jpg

The RECORDS procedure returns a LONG integer containing the number of rows in the VIEW's return data set, if no KEY fields are used in the VIEW's ORDER attribute.

For non-SQL file systems, if a KEY field is used in the VIEW's ORDER attribute, then RECORDS returns negative one (-1). RECORDS can only return a valid value in the cases where the VIEW engine must build its own index of all the records in the return data set. For those non-SQL VIEWs which do use a KEY field in the ORDER attribute, Clarion's VIEW engine optimizations make use of that KEY (allowing for faster overall processing), so no index is built and the number of records in the return data set is therefore not known.

Return Data Type:     LONG

Example:

SomeProc PROCEDURE(LocationQueue Location)  !receives named QUEUE structure

Customer FILE,DRIVER('Clarion'),PRE(Cus)

AcctKey   KEY(Cus:AcctNumber)

NameKey   KEY(Cus:Name)

Record    RECORD

AcctNumber  LONG

Name        STRING(20)

Addr        STRING(20)

CSZ         STRING(60)

         END

        END

Header  FILE,DRIVER('Clarion'),PRE(Hea)

AcctKey  KEY(Hea:AcctNumber)

OrderKey KEY(Hea:OrderNumber)

Record   RECORD

AcctNumber  LONG

OrderNumber LONG

OrderAmount DECIMAL(11,2)

        END

       END

ViewOrder VIEW(Customer),ORDER('Cus:Name,-Hea:OrderAmount') !ORDER without KEY fields

          PROJECT(Cus:AcctNumber,Cus:Name)

          JOIN(Hea:AcctKey,Cus:AcctNumber)

           PROJECT(Hea:OrderNumber)

            PROJECT(Hea:OrderAmount)

          END

         END

SaveCount     LONG

SaveNameCount LONG

CODE

OPEN(Customer)

OPEN(Header)

SaveCount = RECORDS(Customer)        !Save the record count

SaveNameCount = RECORDS(Cus:NameKey) !Number of records with names filled in

OPEN(ViewOrder)

MESSAGE(“Records in VIEW = ' & RECORDS(ViewOrder))

Entries# = RECORDS(Location)         !Determine number of entries in passed QUEUE

LOOP I# = 1 TO Entries#              !Loop through QUEUE

 GET(Location,I#)                    !getting each entry

 ASSERT(NOT ERRORCODE())

 DO SomeProcess                      !process the entry

END  

See Also:

QUEUE

ADD

KEY

INDEX

OPT

records_return_number_of_rows_in_data_set_.htm.txt · Last modified: 2021/04/15 15:57 (external edit)