I'm trying out the "Locate" feature and I don't quite understand how it works.
I have a table with 20,000 records with the column "Id" as PK.
I have a TMYQuery (Qy_Risk) with "select * from tas_riesgo" in the "SQL.Text" property
I am testing the time difference using Locate:
Case 1:
I don't report the IndexFieldNames property
Case 2:
I report the IndexFieldNames property with value "Id"
I execute the following instruction for both cases:
Code: Select all
procedure TMain.Bt_SearchIdCLick(Sender: TObject);
var
Ini: TDateTime;
begin
Ini := Now();
if Qy_Riesgos.Locate('Id', StrToInt(Ed_Id.Text), []) then
ShowMessage(IntToStr(DateUtils.MilliSecondsBetween(now(), Ini)));
end;
The idea is to position myself in a TmyQuery record through its PK (Id) using the Locate method
Best Regads