It's correct to used While like this
while not BatchQry.EOF do Begin
Example :
Try
Session.StartTransaction;
while not BatchQry.EOF do Begin
s := StripChargenumber( BatchQry.FieldByName('tmpChargenumber').asString);
// Showmessage(s);
if Length(s) > 0 then
begin
With MyTb do
begin
insert;
FieldByName('EmplId').asinteger := BatchQry.FieldByName('tmpEmplId').asinteger;
FieldByName('chargeNumber').AsString := BatchQry.FieldByName('tmpChargenumber').asString;
FieldByName('OperationNumber').asInteger := BatchQry.FieldByName('tmpOperationNumber').asInteger;
FieldByName('TotalHoursSeq').asFloat:= BatchQry.FieldByName('tmpTotalHourSeq').AsFloat;
FieldByName('TotalhoursSeq_Reg').asFloat:= BatchQry.FieldByName('TmpTotalHourSeq_reg').AsFloat;
FieldByName('TotalhoursSeq_Suppl').asFloat:= BatchQry.FieldByName('TmpTotalHourSeq_Over').AsFloat;
FieldByName('DateTransaction').AsDateTime := BatchQry.FieldByName('tmpDateTransaction').asDateTime;
FieldByName('NeedtoCompleted').asBoolean := BatchQry.FieldByName('tmpNeedToCompleted').asBoolean;
FieldByName('HasModified').asString:= '0';
FieldByName('WorkOrder').asString := UPPERCASE(s);
FieldByName('ProjetId').asString := BatchQry.FieldByName('TmpUr').asString;
FieldByName('EquipmentID').asInteger := BatchQry.FieldByName('tmpEquipmentID').Asinteger;
post;
end; //with MyTb
end;// if Length
BatchQry.Edit;
BatchQry.FieldByName('tmpBatchMove').asinteger:= 1;
BatchQry.post;
s:='';
BatchQry.Next;
End; // while not ADQ.EOF
MyTb.ApplyUpdates; {try to write the updates to the database}
Session.Commit; {on success, commit the changes}
Except
MyTb.RestoreUpdates; {restore update result for applied records}
Session.Rollback; {on failure, undo the changes}
raise; {raise the exception to prevent a call to CommitUpdates!}
End;
MyTb.CommitUpdates; {on success, clear the cache}