In this particular instance, yes, it is easy to do the updates with a single call to ExecSQL()
.
If the IDs are sequential, you can do this:
var
text: string ; // data i take from table in my loop.
query.SQL.Text := 'Update dbtable Set atext=' + QuotedStr(text) + ' Where id >= 1 and id <= 100';
query.ExecSQL;
If the IDs are not sequential, you could use an in
clause instead, but this is less efficient if you have a large list of IDs:
var
text: string ; // data i take from table in my loop.
query.SQL.Text := 'Update dbtable Set atext=' + QuotedStr(text) + ' Where id in [1, ..., 100]';
query.ExecSQL;
Another option would be to create a stored procedure in the DB. Have it take the text and IDs as paramenters, and then perform any needed looping internally. You can then perform a single SQL statement in your code to execute the stored procedure with parameter values.