Strange behavior with IndexName in kbmMemTable v. 7.85.00

Home Forums kbmMemTable Strange behavior with IndexName in kbmMemTable v. 7.85.00

Viewing 5 reply threads
  • Author
    Posts
    • #55406
      ivanyuzafatau
      Participant

      I am comparing two versions of the kbmMemTable component: 4.08b and 7.85.00.

      I have a demo application in Delphi 7 using version 4.08b. I also have a demo application in Delphi 10.3 using version 7.85.00.

      Both apps have tables with a master/detail relationship.

      If I execute the following code:

      kbmMemTable1.IndexName := ”;

      the master/detail relationship stops working in Delphi 10.3! I see all the records in the detail table.

      But in Delphi 7 the master/detail relationship is not broken!

      Why is this behavior in the new version of kbmMemTable? Can this be fixed?

    • #55408
      ivanyuzafatau
      Participant

      I will add to my question.

      kbmMemTable1 is a detail table. tMaster is a master table.

      tMaster.Active:=true;
      kbmMemTable1.DetailFields:=’CustNo’;
      kbmMemTable1.MasterSource:=dsMaster;
      kbmMemTable1.MasterFields:=’CustNo’;

    • #55409
      kimbomadsen
      Keymaster

      Hi,

      The reason is that kbmMemTables way of doing m/d and range handling has been changed completely in v. 7.00 to take advantage of indexes rather than table scans.

      So when you define a master/detail relation, a detail index will be automatically created (and updated when you change the master), and you can quickly move around in the detail records even when there are loads of them.

      You can also define a sort order on the data within the detail index, which is done behind the scenes, when you either use Sort or set IndexFieldNames. Then a new index will be created, which will be based on the previous index (the m/d index), and thus will only contain records matching the m/d index.

      Setting IndexNames to an empty string basically in all versions including 7.90 means reverting to use the row order index (which is the index holding all records in the order they were originally inserted into the table), which is what you see.

      I have changed that behaviour in 7.91, which I will shortly release, where either Sort on no fields or setting IndexName to an empty string will make kbmMemTable revoke the current index, making the base index the current unless the current is already either the row order index, or a master/detail index or a range index.

      Then it will work the way you would expect it to work.

      Until the release you can use IndexName:=kbmDetailIndex;

    • #55413
      ivanyuzafatau
      Participant

      Kim, Thank you for the answer!

      <span class=”JLqJ4b ChMk0b” data-language-for-alternatives=”en” data-language-to-translate-into=”ru” data-phrase-index=”2″>I’ve got one more question. I want to use my own index name.</span> If I create and use a sorting index as follows:

      kbmMemTable1.AddIndex(‘Sort’, ‘EmpNo’, [ixDescending]);
      kbmMemTable1.IndexDefs.Update;
      kbmMemTable1.IndexName := ‘Sort’;

      <span class=”JLqJ4b ChMk0b” data-language-for-alternatives=”en” data-language-to-translate-into=”ru” data-phrase-index=”2″>It also doesn’t work in kbmMemTable v.</span> <span class=”JLqJ4b ChMk0b” data-language-for-alternatives=”en” data-language-to-translate-into=”ru” data-phrase-index=”3″>7.85.00.</span> <span class=”JLqJ4b ChMk0b” data-language-for-alternatives=”en” data-language-to-translate-into=”ru” data-phrase-index=”4″>In kbmMemTable v 4.08b this worked well.</span>

      I can send you a demo application that demonstrates the problem.

    • #55414
      ivanyuzafatau
      Participant

      For some reason, my previous comment is broken. I’ll try to add anew..

      I’ve got one more question. I want to use my own index name. If I create and use a sorting index as follows:

      kbmMemTable1.AddIndex(‘Sort’, ‘EmpNo’, [ixDescending]);
      kbmMemTable1.IndexDefs.Update;
      kbmMemTable1.IndexName := ‘Sort’;

      It also doesn’t work in kbmMemTable v. 7.85.00. In kbmMemTable v. 4.08b this worked well.

      I can send you a demo application that demonstrates the problem.

    • #55417
      ivanyuzafatau
      Participant

      I’ve done some research with the new version. I tried creating a custom named sorting index for the master table.

      tMaster.AddIndex(‘Sort’, ‘Company’, [ixDescending]);
      tMaster.IndexDefs.Update;
      tMaster.IndexName := ‘Sort’;

      The sort works on the master table. The index name remains as I specified it.

      But similar code for a detail table has the following consequences:
      1) master/detail relationship no longer works
      2) the IndexName for the detail table changes to ‘__MT__DETAIL_’ if I navigate to another record in the master table

      Can I hope this behavior will change in future versions of kbmMemTable?
      Thank you!

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