Difference between revisions of "lookup"

From Lazarus wiki
Jump to navigationJump to search
(Created page with "{{Translate}} == Definition == Unit: FreePascal, unit '''db''' <syntaxhighlight> function Lookup(const KeyFields: string; const KeyValues: Variant; const ResultFields: s...")
 
m (Fixed syntax highlighting)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Translate}}
+
{{lookup}}
  
 
== Definition ==
 
== Definition ==
 +
 
Unit: FreePascal, unit '''db'''
 
Unit: FreePascal, unit '''db'''
  
<syntaxhighlight>
+
<syntaxhighlight lang=pascal>
 
     function Lookup(const KeyFields: string; const KeyValues: Variant; const ResultFields: string): Variant;
 
     function Lookup(const KeyFields: string; const KeyValues: Variant; const ResultFields: string): Variant;
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 11: Line 12:
  
 
== Description ==
 
== Description ==
'''lookup''' is similar to '''locate'' in that it looks for a record in the dataset where the specified search values for the specified fields match.  
+
 
 +
'''lookup''' is similar to [[locate]] in that it looks for a record in the dataset where the specified search values for the specified fields match.  
  
 
If found, the function returns a variant array with the values of the ResultFields (a semicolon-delimited list of desired fields).
 
If found, the function returns a variant array with the values of the ResultFields (a semicolon-delimited list of desired fields).
Line 22: Line 24:
  
 
{{Note|Lookup is only implemented in non-unidirectional datasets, i.e. you must be able to move back and forwards through the dataset.}}
 
{{Note|Lookup is only implemented in non-unidirectional datasets, i.e. you must be able to move back and forwards through the dataset.}}
 
  
 
== See also ==
 
== See also ==
* [http://delphi.about.com/od/database/l/aa052901a.htm] Description of how to use lookup with Delphi
 
  
[[category:FPC]]
+
* [[locate]]
[[category:Databases]]
+
* [http://delphi.about.com/od/database/l/aa052901a.htm Description of how to use lookup with Delphi]

Latest revision as of 06:55, 19 February 2020

English (en) français (fr)

Definition

Unit: FreePascal, unit db

    function Lookup(const KeyFields: string; const KeyValues: Variant; const ResultFields: string): Variant;

Official documentation: none

Description

lookup is similar to locate in that it looks for a record in the dataset where the specified search values for the specified fields match.

If found, the function returns a variant array with the values of the ResultFields (a semicolon-delimited list of desired fields). If not found, it returns Null. In neither case does it change the current physical record/cursor.

KeyFields can be a single field name or a semicolon-separated list of fields.

KeyValue can be a variant or a variant array and the number of items must match the number of fields specified in KeyFields.

Note-icon.png

Note: Lookup is only implemented in non-unidirectional datasets, i.e. you must be able to move back and forwards through the dataset.

See also