I need to perform many searches by primary key field of table:
Code: Select all
CREATE TABLE List1 (
ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
Name VARCHAR
);
I try to search like this:
Code: Select all
var
NewIDsFound:Integer;
begin
LocalQuery.SQL.Add('SELECT Name FROM List1 WHERE ID=:myid');
LocalQuery.Prepare;
LocalQuery.DisableControls;
NewIDsFound:=0;
for i := 0 to InList.Count-1 do
begin
LocalQuery.Params[0].AsInteger:=InList.IntValue[i];
LocalQuery.ExecSQL;
if LocalQuery.eof then
Inc(NewIDsFound);
end;
LocalQuery.Unprepare;
end;