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:
b12 cannot limit records returned and more. (1997)
WebCat2b15MacPlugin - showing [math] (1997)
View Source from cache (1997)
WebCat2 beta 11 - new prefs ... (1997)
Re1000001: Setting up shop (1997)
emailer error -108 (1997)
WebCat2: Master Counter snippet (1997)
Re:quit command on NT (1997)
SiteEdit NewFile.html ? (1997)
Linux ODBC and the ODBC Bridge (2000)
[Sum] function? (1997)
[SEARCH] Context for SKU prices not working... (1998)
Showif (2000)
Re:2nd WebCatalog2 Feature Request (1996)
WebCat2b13 Command Reference Doc error (1997)
Searching Numbers (2004)
4.5.1 on Panther? (2004)
WebCat2b12--[searchstring] bug (1997)
Outsourcing portals and CodeLane.com (2005)
HomePage Caution (1997)