Unrecognized token error for MasterFields names with spaces using SmartFetch
Posted: Mon 21 May 2018 19:45
I am attempting to implement SmartFetch to reduce the memory usage of an application that opens a large database. I received unrecognized token errors when opening a linked detail table where the MasterFields field name contains spaces. The tables linked correctly when the IndexFieldNames property was used however SmartFetch with LiveBlock enabled requires the IndexFieldNames property to be blank so that property assignment was replaced by assigning the KeyFields and OrderFields properties. The detail table will open without errors until I setup the MasterFields/DetailFields with SmartFetch enabled.
I stepped through the table initialization and isolated the problem to the MasterFields by changing to a field without a space in the name which allowed the table to open without the error. I also tried commenting out the SmartFetch.Enabled = True statement when the MasterFields property used the name with spaces and the table also opened without errors. My final workaround attempt was to replace the "Test Set ID"' quotes with [Test Set ID] brackets like the TLiteTable default SQL statements but the same error was generated.
My initial testing of SmartFetch with LiveBlock resulted in a huge reduction in the amount of memory used for opening a large archive table and will solve several problems using our large databases. Any suggestions about how to make this work or did I discover a TLiteTable bug?
Original IndexFieldNames Table Setup:
New SmartFetch/KeyFields/OrderFields Setup:
I stepped through the table initialization and isolated the problem to the MasterFields by changing to a field without a space in the name which allowed the table to open without the error. I also tried commenting out the SmartFetch.Enabled = True statement when the MasterFields property used the name with spaces and the table also opened without errors. My final workaround attempt was to replace the "Test Set ID"' quotes with [Test Set ID] brackets like the TLiteTable default SQL statements but the same error was generated.
My initial testing of SmartFetch with LiveBlock resulted in a huge reduction in the amount of memory used for opening a large archive table and will solve several problems using our large databases. Any suggestions about how to make this work or did I discover a TLiteTable bug?
Original IndexFieldNames Table Setup:
Code: Select all
With TestListLiteTable do
begin
Close;
Connection := WC6SourceLite;
TableName := 'CSetList';
Options.StrictUpdate := False;
Options.QuoteNames := True;
Options.QueryRecCount := True;
stKey := '"Test Set ID"; EquipmentID';
IndexFieldNames := stKey;
DetailFields := '"Test Set ID"';
MasterFields := '"Test Set ID"';
MasterSource := TestSetDS;
Open;
end;
Code: Select all
With TestListLiteTable do
begin
Close;
Connection := WC6SourceLite;
TableName := 'CSetList';
Options.StrictUpdate := False;
Options.QuoteNames := True;
Options.QueryRecCount := True;
stKey := '"Test Set ID"; EquipmentID';
KeyFields := stKey;
SmartFetch.PreFetchedFields := stKey;
SmartFetch.Enabled := True; <<<--- Comment out and table opens without error!
stOrd := '"Test Set ID", EquipmentID';
OrderFields := stOrd;
DetailFields := '"Test Set ID"';
MasterFields := '"Test Set ID"';
MasterSource := TestSetDS;
Open;
end;