EPUB | CHM | PDF

TMySQLTable.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 MySQL tables, the key may correspond to a specified index in IndexName, or to a list of field names in the TMySQLTable.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 and master-detail tables will not work properly too because of their dependence on Locate method. Please update your IDE to BDS 2006 (or later) or don't use BIGINT and UNSIGNED INT datatypes for keys and indexes if you need to use them in lookup fields. Also you can't use variant-style properties (FieldValuesAsVariant and so on) with such fields.