Problem using a filter

Home Forums kbmMemTable Problem using a filter

Viewing 5 reply threads
  • Author
    Posts
    • #55751
      SueK
      Participant

      I have an issue where a filter works sometimes and not other times, and I cannot see what is different.

      The table is defined by

      FDataTable.FieldDefs.Add(‘RemoteNo’, ftWord, 0, TRUE {required});
      FDataTable.FieldDefs.Add(‘DataNo’, ftSmallInt, 0, TRUE {required});
      FDataTable.FieldDefs.Add(‘SubDataNo’, ftSmallInt, 0, TRUE {required});
      FDataTable.FieldDefs.Add(‘ElementNo’, ftLongWord, 0, TRUE {required});
      FDataTable.FieldDefs.Add(‘BlockNo’, ftSmallInt, 0, TRUE {required});
      FDataTable.FieldDefs.Add(‘ElementId’, ftString, 20, TRUE {required});
      FDataTable.FieldDefs.Add(‘DataOrigin’, ftFixedChar, 1, TRUE {required});
      FDataTable.FieldDefs.Add(‘DataMatch’, ftFixedChar, 1, FALSE {required});
      FDataTable.FieldDefs.Add(‘LastModified’, ftDateTime, 0, FALSE {required});
      FDataTable.FieldDefs.Add(‘DLUpdate’, ftFixedChar, 1, FALSE {required});
      FDataTable.FieldDefs.Add(‘ExtraInfo1’, ftLongWord, 0, FALSE {required});
      FDataTable.FieldDefs.Add(‘DLBinary’, ftVarBytes, 132, FALSE {required});

      The index is defined by

      FDataTable.AddIndex(‘INDEX_FEDataMatch’, ‘RemoteNo;DataNo;ElementNo;ElementId;SubDataNo;BlockNo’,[]);

      There are other indexes.

      The index is set to INDEX_FEDataMatch.

      There are three records in the table. The key values are

      1,23,1,”,0,0

      1,23,2,”,2,0

      1,23.3,”,0,0′

      The filter is changed for each read, and FindFirst is called.   Because of the nature of the application, FindNext is not appropriate.

      The initial read filter is ‘ (DataOrigin = ‘G’) and (DataNo = 23 )’

      The rest of the reads use ‘ (DataOrigin = ‘G’) and (DataNo = 23 ) and (ElementNo > nn)’

      where nn is the elementno returned in the previous find.

      In the console based test program, all 3 records are returned.  In the application, only items 1 and 3 are returned.

      Item 2 has been deleted and re-added with a different SubDataNo (in both cases).

      Do you have any idea what might be going wrong?  I can send you the saved data files, if you would like to look at them.  I have been looking at this for several days now, and have eliminated possibilities, but not found the answer.

      Regards

      Sue

    • #55752
      SueK
      Participant

      I should have mentioned I am using 7.92 in Delphi 10.4.2

      Sue

      • This reply was modified 4 years, 10 months ago by SueK.
    • #55769
      kimbomadsen
      Keymaster

      Hi Sue,
      Could you send me a very small application not requiring any 3rdparty components and sample data, that illustrates the problem, then I will have a look at it.
      Send to kbm@components4developers.com
      /Kim

    • #55772
      SueK
      Participant

      Hi Kim,

      I will prepare something.  I am restructuring my code to simplify it, in case there is something I am doing wrong that I have missed.

      Thanks,

      Sue

    • #55775
      kimbomadsen
      Keymaster

      Hi,

      I have replied back.

      After several hours of looking into your code vs. kbmMemTable, I can conclude that there are no problems in kbmMemTables filtering mechanism, but your convoluted selection algorithm has flaws in how it iterates records.

      One specific thing you must keep in mind is how FindNearest default find a nearest record when there is no complete match. It will return the record before the least highest match according to the currently selected index.

      That behaviour can be altered by the last optional argument of FindNearest.

      /Kim

    • #55806
      SueK
      Participant

      For those interested, the problem was in my code.

      Thanks, Kim, for the help

      Sue

Viewing 5 reply threads
  • You must be logged in to reply to this topic.