Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 9 of 9 total |
Processing Filtered Dataset |
Fri, Feb 1 2008 11:34 AM | Permanent Link |
Gordon Turner | I'm setting a filter on a table and then processing the results.
Depending on the contents of the filtered field I either want to change the contents, or handle the record in another way. I'm not clear what happens to the record pointer when I change the contents of a filtered field so that it no longer matches the filter. The docs say... "If the current record pointer does not fall into the conditions specified by an expression filter, then the current record pointer will be moved to the nearest record that falls within the filtered set of records." But what constitutes the nearest record? Sometimes it is the next record, sometimes it is the previous record. Is there some other rule I can use to decide how to proceed through my record set when I change the filtered field? If there are no more records in the dataset can I assume the EOF condition is true or do I need to test for BOF as well? -- Gordon Turner Mycroft Computing http://www.mycroftcomputing.com |
Fri, Feb 1 2008 12:13 PM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Gordon
Its very simple. You need a loop like while not table.eof do begin if something then begin change the record table.post; if changes have invalidated the filter do nothing else table.next; end else table.next; end; Its caught me out many times. The rule is clear: If the changes to the record will result in the record not matching the filter condition then the record will "disapear" on post. Roy Lambert |
Fri, Feb 1 2008 1:25 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Gordon,
<< But what constitutes the nearest record? >> It's the next closest record in index order that satisfies the filter. If there are no more records after the record that was removed, then the next closest record will be the previous record. << If there are no more records in the dataset can I assume the EOF condition is true or do I need to test for BOF as well? >> Are you trying to update all records in the filtered set ? If so, then just use this: with MyDBISAMTable do begin First; while (RecordCount > 0) do begin // Edit and Post updates First; end; end; -- Tim Young Elevate Software www.elevatesoft.com |
Fri, Feb 1 2008 1:39 PM | Permanent Link |
Gordon Turner | Tim Young [Elevate Software] wrote:
> > It's the next closest record in index order that satisfies the filter. If > there are no more records after the record that was removed, then the next > closest record will be the previous record. > OK, that is what was causing the problem. I was looping until EOF and when I changed the filtered property in the last record in the set the pointer jumped back to the previous record causing me to process it twice. Short of using a Next/Prev command to test, is there any other way to tell if I'm on the last record in a data set? That way I can do a Next and make EOF true. -- Gordon Turner Mycroft Computing http://www.mycroftcomputing.com |
Fri, Feb 1 2008 1:40 PM | Permanent Link |
Gordon Turner | Roy Lambert wrote:
> > Its very simple. You need a loop like > > while not table.eof do begin > if something then begin > change the record > table.post; > if changes have invalidated the filter do nothing else table.next; > end else table.next; > end; > Except if the last record in the set disappears upon Post, EOF will NOT be true and the active record will be the previous record in the data set. -- Gordon Turner Mycroft Computing http://www.mycroftcomputing.com |
Fri, Feb 1 2008 1:53 PM | Permanent Link |
"Robert" | "Gordon Turner" <gordon@mycroftcomputing.com> wrote in message news:58DA3480-CCE1-4EE2-817C-6DE501245BF7@news.elevatesoft.com... > Roy Lambert wrote: >> >> Its very simple. You need a loop like >> >> while not table.eof do begin >> if something then begin >> change the record >> table.post; >> if changes have invalidated the filter do nothing else table.next; >> end else table.next; >> end; >> > > Except if the last record in the set disappears upon Post, EOF will NOT be > true and the active record will be the previous record in the data set. > LOL, it's a matter of definition, I guess. EOF is NOT true at that point. Is BOF true? Also, EOF should be true before you change the record. Robert |
Fri, Feb 1 2008 4:36 PM | Permanent Link |
Gordon Turner | Robert wrote:
> > LOL, it's a matter of definition, I guess. EOF is NOT true at that point. Is > BOF true? May or may not be depending on whether there are other records in the dataset. > Also, EOF should be true before you change the record. I don't think so. EOF is not True until you pass the end of the data set. That's why you don't get an exception in the following: while not EOF do begin {process record} Next; end; When the Next method moves the record pointer beyond the end of the data set EOF becomes true. EOF is not true on the last record or else you would never process the last record in the above loop. -- Gordon Turner Mycroft Computing http://www.mycroftcomputing.com |
Sat, Feb 2 2008 5:02 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Gordon
Didn't know that processing one record twice would be a problem. Two solutions: 1. Set a counter to the filtered record count before entering the loop, decrement it each time round and force an exit when its 0. 2. After processing any record stuff its key into a variable, before the next process check if its the same as the current record, if it is force an exit. You only need to worry about capturing/checking the key when it doesn't get filtered out. Roy Lambert |
Mon, Feb 4 2008 3:43 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Gordon,
<< Except if the last record in the set disappears upon Post, EOF will NOT be true and the active record will be the previous record in the data set. >> This is due to the fact that we try to not to ever set EOF unless a) the dataset is empty or b) you actively attempt to navigate past the end of the dataset. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Sunday, May 5, 2024 at 07:30 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |