Home › Forums › kbmMemTable › Problem using a filter
- This topic has 5 replies, 2 voices, and was last updated 4 years, 9 months ago by
SueK.
-
AuthorPosts
-
-
May 14, 2021 at 03:43 #55751
SueK
ParticipantI 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
-
May 14, 2021 at 05:41 #55752
-
May 16, 2021 at 22:59 #55769
kimbomadsen
KeymasterHi 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 -
May 17, 2021 at 02:10 #55772
SueK
ParticipantHi 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
-
May 24, 2021 at 00:48 #55775
kimbomadsen
KeymasterHi,
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
-
May 28, 2021 at 06:52 #55806
SueK
ParticipantFor those interested, the problem was in my code.
Thanks, Kim, for the help
Sue
-
-
AuthorPosts
- You must be logged in to reply to this topic.
