FireDAC.Comp.DataSet.TFDDataSet.FindKey

From RAD Studio API Documentation
Jump to: navigation, search

[–] Properties
Type: function
Visibility: public
Source:
FireDAC.Comp.DataSet.pas
FireDAC.Comp.DataSet.hpp
Unit: FireDAC.Comp.DataSet
Parent: TFDDataSet

Delphi

function FindKey(const AKeyValues: array of const): Boolean;

C++

bool __fastcall FindKey(const System::TVarRec *AKeyValues, const System::NativeInt AKeyValues_High);

Description

Searches for a record containing specified index field values.

Use FindKey to search for the record in an indexed dataset using specified index field values.

AKeyValues is an open array containing field values called a key. Each value in the key can be a literal, a variable, or nil. If the number of values passed in AKeyValues is less than the number of columns in the index used for the search, the missing values are assumed to be nil.

If a search is successful, FindKey positions the cursor on the matching record and returns True. Otherwise, the cursor is not moved and FindKey returns False.

Example

FDQuery1.IndexFieldNames := 'F1;F2';
if not FDQuery1.FindKey([100, 'qwe']) then
  ShowMessage('100;qwe is not found');

See Also