Browse Source

* Patch from Ludo Brands implementing TCustomBufdataset.lookup
Mantis #22099

git-svn-id: trunk@21364 -

marco 13 years ago
parent
commit
283b37139f
1 changed files with 22 additions and 0 deletions
  1. 22 0
      packages/fcl-db/src/base/bufdataset.pas

+ 22 - 0
packages/fcl-db/src/base/bufdataset.pas

@@ -518,6 +518,7 @@ type
     procedure CancelUpdates; virtual;
     destructor Destroy; override;
     function Locate(const keyfields: string; const keyvalues: Variant; options: TLocateOptions) : boolean; override;
+    function Lookup(const KeyFields: string; const KeyValues: Variant; const ResultFields: string): Variant; override;
     function UpdateStatus: TUpdateStatus; override;
     function CreateBlobStream(Field: TField; Mode: TBlobStreamMode): TStream; override;
     procedure AddIndex(const AName, AFields : string; AOptions : TIndexOptions; const ADescFields: string = '';
@@ -3139,6 +3140,27 @@ begin
     end;
 end;
 
+function TCustomBufDataset.Lookup(const KeyFields: string;
+  const KeyValues: Variant; const ResultFields: string): Variant;
+var
+  bm:TBookmark;
+begin
+  result:=nil;
+  bm:=GetBookmark;
+  DisableControls;
+  try
+    if Locate(KeyFields,KeyValues,[]) then
+      begin
+//      CalculateFields(ActiveBuffer); // not needed, done by Locate more than once
+      result:=FieldValues[ResultFields];
+      end;
+    GotoBookmark(bm);
+    FreeBookmark(bm);
+  finally
+    EnableControls;
+  end;
+end;
+
 { TArrayBufIndex }
 
 function TArrayBufIndex.GetBookmarkSize: integer;