EPUB | CHM | PDF

TPSQLTable.Methods.FindKey

Top Previous Next

Searches for a record containing specified field values.

Syntax:

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

Description:

Call FindKey to search for a specific record in a dataset. KeyValues contains a comma-delimited array of field values, called a key. Each value in the key can be a literal, a variable, a null, or nil. If the number of values passed in KeyValues is less than the number of columns in the index used for the search, the missing values are assumed to be null.

For PostgreSQL tables, the key may correspond to a specified index in IndexName, or to a list of field names in the IndexFieldNames property.

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

Delphi 7 and prior has poor support for int64 values in variant type. This means that you'll be unable to use Locate() and similar methods with such fields. Lookup fields will not work proper too due to their dependence on Locate() method. Please update your IDE to BDS 2006 or don't use bigint (int8) and bigserial datatypes for keys and indexes if you need to use them in lookup fields.