FireDAC.Comp.DataSet.TFDDataSet.FindKey

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

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

C++

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

Properties

Type Visibility Source Unit Parent
function public
FireDAC.Comp.DataSet.pas
FireDAC.Comp.DataSet.hpp
FireDAC.Comp.DataSet TFDDataSet

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