Vote UpVote

Deleting Dataset Records In a Loop - Poll Results - Why All Records Are Not Deleted

About Delphi Programming – in Poll :: Several days ago I've posted a poll asking how many records (in %) would get deleted in a loop like: var ds : TSomeDataSet begin ds.First; while NOT ds.Eof do begin if TRUE then ds.Delete; ds.Next; end; end; At the first look you might be tempted to say "all" (or 100%) - but you would be wrong. Out of some 1600 votes only 60% of the answers were correct. The above code would delete 50% of the records. To be precise the exact number of deleted records would be ((n-1)/2)+1 if n is the number of records in the dataset before the loop. Why only every second ...
Favorite? Off-Topic? 2012-02-16 04:00


Visits: 422
Votes: 1
Favorites: 0
Off-Topic: 0

Visits by Source

User Actions

Users who voted for this posting

Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News


Please login or register to use this functionality.
(click on this box to dismiss)