The (D7) documentation for
A newly appended record is posted to the database in one of three ways:
For indexed Paradox and dBASE tables, the record is inserted into the dataset in a position based on its index.
For unindexed Paradox and dBASE tables, the record is added to the end of the dataset.
For SQL databases, the physical location of the appended record is implementation-specific. For indexed tables, the index is updated with the new record information.
I mention D7 because TAdsTable and TAdsQuery date from around that era, or a bit before, and were
intended to be similar to TTable and TQuery, which were for working with datasets implemented using
te obsolete BDE (Borland Database Engine).
In the example you quote, you have a dataset with a single field and you are repeatedly appending
records with indistinguishable values ('123') into it, and the behaviour you see is similar
to what you would get if you repeatedly added identical records to a
file of record while
traversing it in physical order.
I don't have the Advantage components myself, but can confirm that the same endless loop
occurs with a BDE TQuery and TTable. The reason is obvious (and I would expect the same
explanation would be true of Advatage):
Operations on the Table cannot affect the current cursor state of the Query, BUT
the Query re-evaluates its EOF condition after each call to
succeeds because the records added by the Table are indistinguishable from the others
found by the
Query's WHERE condition. There is no way of avoiding that while
Query and the
Table are both accessing the same underlying dataset and
the rows added by the
Table satisfy the
Query's WHERE clause. A bit to my surprise, this endless loop behaviour occurs even when the
RequestLive property is false.
So, if you cannot avoid the WHERE clause point, the simplest way to avoid the problem
would be to iterate a temporary copy of the dataset, rather than the dataset itself, e.g. by using Advantage's equivalent
of the BDE's
TBatchMove component to create the copy table and then iterare that instead of th
Query`'s result set. I hope the code necessary to do this is self-evident, but if not I could add a BDE example.
Btw, if the TAdsQuery supports
Insert, you realise that youu could dispense with the
TAdsTable and add the extra rows using the