Re: Date or time comparisons have bugs ...
This WebDNA talk-list message is from 1998
It keeps the original formatting.
numero = 16983
interpreted = N
texte = Ken-The problem is not in your [Search] parameters, but in the fact that youare doing a [Delete] within a [FoundItems] loop.I'm sure that Grant can explain this better than I can, but when you do asearch, WebCat creates its own internal list of matching items andremembers them by their positions in the database. [FoundItems] then loopsthrough each of those records, first performing the desired operations onthe first found record in the db, then on the second, etc. Having a[Delete] inside [FoundItems] messes this up, because it changes theposition of records in your database.For example, say the [Search] finds records 1,2,and 6. On the first[FoundItems] loop, record 1 is deleted. With record 1 gone, the originalrecord 2 becomes record 1, and every other record moves up a position(2->1, 3->2, 4->3, etc.). So when [FoundItems] comes through looking forrecord 2, it is really finding the original record 3, which may or may nothave met the search criteria. The original record 2 gets skipped altogether.Of course, you can avoid all of this by building the search criteria intoyour [Delete]:[Deletedb=this.db&ledeleteDatedatarq=[date]&ledeleteTimedatarq=[time]&deleteDatetype=date]-Dave>Date: 9 Apr 1998 08:26:04>From: Kenneth Grome
>Subject: Date or time comparisons have bugs ...>>I have three fields in this.db: cartID, deleteDate and deleteTime,>corresponding to the following data:>>296987757 02/10/1998 13:59:35>296987758 02/10/1998 13:59:49>296987760 02/10/1998 14:00:00>297229722 03/10/1998 14:07:10>297422049 04/01/1998 20:21:39>297489625 04/09/1998 16:04:12>297489636 04/09/1998 16:06:08>>>My code, which is designed to delete records, looks like this:>>[search>db=this.db&ledeleteDatedatarq=[date]&ledeleteTimedatarq=[time]&deleteDatetype=d>ate]>[founditems]>[delete db=this.db&eqcartIDdatarq=[cartID]]>[/founditems]>[/search]>>So why doesn't it delete all but the last three records?>>Clearly it *should* delete the first 4 records because both the dates AND the>times are *less than* the current date and time, which is 04/08/1998 and>16:12:00 ... so, is there a bug in WebCatalog's code that's causing this>problem?>>Or is there a better way of coding this stuff so that it actually works?>>Sincerely,>Ken Grome>808-737-6499>WebDNA Solutions>mailto:ken@webdna.net>http://www.webdna.net>o--------------- Dave MacLeay --+o----------- Digital Frontier --+o--- dave@digitalfrontier.com --+
Associated Messages, from the most recent to the oldest:
Ken-The problem is not in your [search] parameters, but in the fact that youare doing a [delete] within a [founditems] loop.I'm sure that Grant can explain this better than I can, but when you do asearch, WebCat creates its own internal list of matching items andremembers them by their positions in the database. [founditems] then loopsthrough each of those records, first performing the desired operations onthe first found record in the db, then on the second, etc. Having a[delete] inside [founditems] messes this up, because it changes theposition of records in your database.For example, say the [search] finds records 1,2,and 6. On the first[founditems] loop, record 1 is deleted. With record 1 gone, the originalrecord 2 becomes record 1, and every other record moves up a position(2->1, 3->2, 4->3, etc.). So when [founditems] comes through looking forrecord 2, it is really finding the original record 3, which may or may nothave met the search criteria. The original record 2 gets skipped altogether.Of course, you can avoid all of this by building the search criteria intoyour [delete]:[Deletedb=this.db&ledeleteDatedatarq=[date]&ledeleteTimedatarq=[time]&deleteDatetype=date]-Dave>Date: 9 Apr 1998 08:26:04>From: Kenneth Grome >Subject: Date or time comparisons have bugs ...>>I have three fields in this.db: cartID, deleteDate and deleteTime,>corresponding to the following data:>>296987757 02/10/1998 13:59:35>296987758 02/10/1998 13:59:49>296987760 02/10/1998 14:00:00>297229722 03/10/1998 14:07:10>297422049 04/01/1998 20:21:39>297489625 04/09/1998 16:04:12>297489636 04/09/1998 16:06:08>>>My code, which is designed to delete records, looks like this:>>[search>db=this.db&ledeleteDatedatarq=[date]&ledeleteTimedatarq=[time]&deleteDatetype=d>ate]>[founditems]>[delete db=this.db&eqcartIDdatarq=[cartID]]>[/founditems]>[/search]>>So why doesn't it delete all but the last three records?>>Clearly it *should* delete the first 4 records because both the dates AND the>times are *less than* the current date and time, which is 04/08/1998 and>16:12:00 ... so, is there a bug in WebCatalog's code that's causing this>problem?>>Or is there a better way of coding this stuff so that it actually works?>>Sincerely,>Ken Grome>808-737-6499>WebDNA Solutions>mailto:ken@webdna.net>http://www.webdna.net>o--------------- Dave MacLeay --+o----------- Digital Frontier --+o--- dave@digitalfrontier.com --+
Dave MacLeay
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...
Related Readings:
Count how many items in a summ total (2003)
Three new problems ... (1997)
Great product and great job ! (1997)
[WebDNA] [sendmail] inside search (2016)
2.0.1 new commands and contexts (1997)
Progress !! WAS: Trouble with formula.db (1997)
[WebDNA] v7 Stress Test and Strange Behaviour (2012)
TeaRoom Order fields email account remain empty even though thewy are filled. (1997)
WebCat B13 Mac CGI -- Frames question (1997)
Carts & Refering URLs (1997)
request for comment tag (1998)
Nesting format tags (1997)
Setheader question (1999)
Re:Emailer and encryption (1997)
Archives not sorting properly (2003)
WebCat2: multiple currency support (1997)
Long/Lat (2002)
Running 2 two WebCatalog.acgi's (1996)
No messages for a week? (2000)
Change Subtotal (2000)