Re: OK to delete records while finding them?

This WebDNA talk-list message is from

2000


It keeps the original formatting.
numero = 32479
interpreted = N
texte = >Is there some inherent danger in deleting a record from a db within >a [founditems] loop which is finding >records in that same db?Yes, this is bad. When you do a [SEARCH], webcat creates an internal list of record numbers. It then uses that list to call up the info from the correct lines. If you do a [DELETE], the internal list stays the same, but the info that's really in the database is wrong.For example, let's say your search returns the first, second, and third records in a database:Sku 1 2 3After the first [DELETE], your db might look like thisSKU 2 3So on the next iteration, webcat will look at the second line. Instead of finding the record with SKU=2, it will find the record with SKU=3. Since it doesn't know you don't want that, bad things happen.A simple solution is to replace a field with a unique phrase/word and then delete all those records after the [FOUNDITEMS] loop is complete (this will preserve the line numbering):[SEARCH db=some.db&neSKUdatarq=[SKU]] [FOUNDITEMS] [REPLACE db=some.db&eqSKUdatarq=[SKU]]SKU=DELETEME[/REpLACE] [/FOUNDITEMS] [/SEARCH] [DELETE db=some.dn&eqSKUdatarq=DELETEME]Michael------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: OK to delete records while finding them? (John Butler 2000)
  2. Re: OK to delete records while finding them? (Kenneth Grome 2000)
  3. Re: OK to delete records while finding them? (Anup Setty 2000)
  4. Re: OK to delete records while finding them? (Michael Winston 2000)
  5. OK to delete records while finding them? (John Butler 2000)
  6. Re: OK to delete records while finding them? (Kenneth Grome 2000)
>Is there some inherent danger in deleting a record from a db within >a [founditems] loop which is finding >records in that same db?Yes, this is bad. When you do a [search], webcat creates an internal list of record numbers. It then uses that list to call up the info from the correct lines. If you do a [delete], the internal list stays the same, but the info that's really in the database is wrong.For example, let's say your search returns the first, second, and third records in a database:Sku 1 2 3After the first [delete], your db might look like thisSKU 2 3So on the next iteration, webcat will look at the second line. Instead of finding the record with SKU=2, it will find the record with SKU=3. Since it doesn't know you don't want that, bad things happen.A simple solution is to replace a field with a unique phrase/word and then delete all those records after the [founditems] loop is complete (this will preserve the line numbering):[SEARCH db=some.db&neSKUdatarq=[SKU]] [founditems] [REPLACE db=some.db&eqSKUdatarq=[SKU]]SKU=DELETEME[/REpLACE] [/FOUNDITEMS] [/SEARCH] [DELETE db=some.dn&eqSKUdatarq=DELETEME]Michael------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/ Michael Winston

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:

WebCat2b13 Command Reference Doc error (1997) Suggestions on best way to work with yyyy/mm/dd (1997) Multiple catalog databases and showcart (1997) WebCat2b13MacPlugIn - [shownext method=post] ??? (1997) Monthly Help File (2000) [searchString] (1997) questions on variations of Ken's [text multi=T]var1=&var2=[/text] (1999) Correction: New WebDNA Example from Olin -- (1998) webmerch and serials - almost there (1997) strange [date] behavior (2001) Looking for a host (1997) Order not created error (1997) [lowercase] and [mixedcase] (1998) SetHeader (1997) Cart ID Duplication (2001) Replace context problem ... (1997) WebCat b15 Mac plug-in (1997) Search/sort in URL Was: GuestBook example (1997) Add to Cart & List of Products (1997) Netscape 3.01 can't see db in form (1997)