View Issue Details

IDProjectCategoryView StatusLast Update
0003510JEDI VCL00 JVCL Componentspublic2006-06-08 08:04
ReporterAriochAssigned Toobones 
Status resolvedResolutionfixed 
PlatformDelphi 5 EntOSwin ntOS Version2000 sp4
Product Version 
Target VersionFixed in Version3.30 
Summary0003510: quick and perhaps ugly Lookup for TJvMemoryData
* Forwarded by Arioch /BDV/
* Newsgroup: jedi.vcl on:
* From: "Arioch /BDV/" <>
* Date: Mon, 13 Feb 2006 01:28:32 +0300
* URL: news://$21j$
* Subj: quick and perhaps ugly Lookup for TJvMemoryData

Hello, All!

cloned from JvDBUtils.pas

perhaps it is not very effecient to create and dispose TList on every call -
but at least it should not be worse, than TJvMemoryData.Lookup :)
Those lists may be cached for example, or something better can be implemented perhaps. Internals of TDataSet seemss not to be documented :(

=========Beginning of the citation==============
function TJvMemoryData.Lookup(const KeyFields: string;
  const KeyValues: Variant; const ResultFields: string): Variant;
  FieldCount: Integer;
  Fields: TList;
  Fld: TField; {BG} //else BAD mem leak on
// Bookmark: TBookmarkStr;
  SaveState: TDataSetState;
  i: integer;
  Matched: boolean;

  function CompareField(var Field: TField; Value: Variant): Boolean; {BG}
    S: string;
    if Field.DataType = ftString then
      if Value = Null then
        Result := Field.IsNull
        S := Field.AsString;
        Result := AnsiSameStr(S, Value);
      Result := (Field.Value = Value);

  function CompareRecord: Boolean;
    I: Integer;
    if FieldCount = 1 then
      Fld := TField(Fields.First); {BG}
      Result := CompareField(Fld, KeyValues) {BG}
      Result := True;
      for I := 0 to FieldCount - 1 do
        Fld := TField(Fields[I]); {BG}
        Result := Result and CompareField(Fld, KeyValues[I]); {BG}
  Result := NULL;
    if IsEmpty then Exit;

  Fields := TList.Create;
    GetFieldList(Fields, KeyFields);
    FieldCount := Fields.Count;
    Matched := CompareRecord;
    if Matched then
       Result := FieldValues[ ResultFields]
    else begin
        SaveState := SetTempState(dsCalcFields);
             for i := 0 to Recordcount - 1 do begin
                RecordToBuffer(Records[i], TempBuffer);
                Matched := CompareRecord;
                if Matched then
            if Matched then Result := FieldValues[ ResultFields];
=========The end of the citation================
TagsNo tags attached.



2006-04-05 06:34

administrator   ~0008975

What does this do?


2006-04-18 16:35

developer   ~0009134

implements TJvMemoryData.Lookup

In one of my projects i use 4 TJvMemoryData components, and 3 of those have fields that are taken from another one, 'main' one.

It is not Master-Detial yet, but TField.Lookup* properties now seem to work with TJvMemoryData


2006-06-08 08:04

administrator   ~0009493

This is now in SVN.

Issue History

Date Modified Username Field Change
2006-02-14 13:28 Arioch New Issue
2006-04-05 06:34 obones Note Added: 0008975
2006-04-05 06:34 obones Status new => feedback
2006-04-18 16:35 Arioch Note Added: 0009134
2006-06-08 08:04 obones Status feedback => resolved
2006-06-08 08:04 obones Resolution open => fixed
2006-06-08 08:04 obones Assigned To => obones
2006-06-08 08:04 obones Note Added: 0009493