TAdsTable/TAdsQuery.AdsGetKeyNum

Advantage TDataSet Descendant

Retrieves the logical key number of the current record with respect to the active index.

Syntax

function AdsGetKeyNum : Longint;

Description

The first record in the index is logical record 1.

If AdsTableOptions.AdsFilterOptions is IGNORE_WHEN_COUNTING and AdsTableOptions.AdsScopeOptions is either RESPECT_SCOPES_WHEN COUNTING or IGNORE_SCOPES_WHEN_COUNTING, this function should return fairly quickly and provide good performance if the active index is not large. If the active index is large, this function could take some time to complete because index keys are literally counted until the current key is reached.

If AdsTableOptions.AdsFilterOptions is RESPECT_WHEN_COUNTING, all records referenced by keys in the index that pass the filter and/or scope/range are skipped through and counted until the current key is reached. Thus, with large indexes where many records pass the filter and/or keys pass the scope/range, this function can be very slow.

Example

AdsTable1.Exclusive := TRUE;

AdsTable1.Active := TRUE;

AdsTable1.AdsCreateIndex( '', 'Tag1', 'LastName;DeptNum', '', '', [] );

AdsTable1.IndexName := 'Tag1';

 

AdsTable1.FindNearest( ['C'] );

lKeyCount := AdsTable1.AdsGetKeyNum;

See Also

AdsGetRecordNum