Ten en cuenta el tema de transacciones
Código:
Query.Close;
Query.SQL.Clear;
Query.SQL.Add('insert into DETALLE_FACTURA (');
Query.SQL.Add('COD_ARTICULO, CANTIDAD, CAMPO_X...)');
Query.SQL.Add('values (:vCOD_ARTICULO, :vCANTIDAD, :vCAMPO_X...)');
while not DetalleTemporal.Eof() do begin
if not Query.Transaction.InTransaction then Query.Transaction.StartTransaction; //agregado
Query.ParamByName('vCOD_ARTICULO').AsString := DetalleTemporalCOD_ARTICULO.AsString;
Query.ParamByName('vCANTIDAD').AsCurrency := DetalleTemporalCANTIDAD.AsCurrency;
...otros campos..
Query.Transaction.Commit; // agregado
DetalleTemporal.Next;
end;
Si hay más de un usuario cargando datos, el hecho de que inserten al mismo tiempo y no cierren transacciones puede hacer más cada vez más lento la inserción de registros.