Re: [WebDNA] Repeated Task [reworking a DB)

This WebDNA talk-list message is from

2015


It keeps the original formatting.
numero = 112112
interpreted = N
texte = > I have no problem in making a duplicate of the DB. Great! > Do you have any suggestion/best practise ... Rather than change existing values I'll give you instructions and code that enters incremental values into a new field: 1- After you duplicate the db, append a tab character then "ix" to the first line of the db (or your .hdr file). This will be the field for your new incremental numbers. 2- Put this code in a new template then request it ONCE: [text]go=[elapsedtime][/text] [math show=f]last=0[/math] [loop start=1&end=99999] [commitdatabase theCopy.db] [waitforfile file=thisFileWillNeverExist&timeout=10][/waitforfile] [search db=theCopy.db&eqixdatarq=[blank]&rank=off&max=500] [replacefounditems]ix=[math]last=last+1[/math][/replacefounditems] [showif [numfound]=0][break][/showif] [/search] [/loop] Processing took [math]([elapsedtime]-[go])/60[/math] seconds. This code will process 500 records at a time, wait 10 seconds before processing the next batch of 500 records, and stop automatically when it has processed every record in the db. The timeout is there to limit the amount of resources consumed by this thread while it is processing the db. It should allow plenty of time for other threads to do their work without causing the server to grind to a halt. When processing is done, just replace the original db with this one. Then in your append contexts use "autonumber=ix" so new records will have incremental values. And when you want to sort in reverse db order use "deixsort=1&ixtype=num". NOTES: 1- You may want to run this code with [loop start=1&end=1] first to see if it works. If it does, you'll also have to ... 2- Change the zero in "[math show=f]last=0[/math]" to the largest number in the "ix" field (otherwise you'll get duplicates with "ix" values of 1-500) ... then use [loop start=1&end=99999] before you run the code again. Regards, Kenneth Grome WebDNA Solutions http://www.webdnasolutions.com Web Database Systems and Linux Server Management Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] Repeated Task [reworking a DB) (Stuart Tremain 2015)
  2. Re: [WebDNA] Repeated Task [reworking a DB) (Kenneth Grome 2015)
  3. Re: [WebDNA] Repeated Task [reworking a DB) (Palle Bo Nielsen 2015)
  4. Re: [WebDNA] Repeated Task [reworking a DB) (Kenneth Grome 2015)
  5. Re: [WebDNA] Repeated Task [reworking a DB) (Palle Bo Nielsen 2015)
  6. Re: [WebDNA] Repeated Task [reworking a DB) (Terry Wilson 2015)
  7. [WebDNA] Repeated Task [reworking a DB) (Palle Bo Nielsen 2015)
> I have no problem in making a duplicate of the DB. Great! > Do you have any suggestion/best practise ... Rather than change existing values I'll give you instructions and code that enters incremental values into a new field: 1- After you duplicate the db, append a tab character then "ix" to the first line of the db (or your .hdr file). This will be the field for your new incremental numbers. 2- Put this code in a new template then request it ONCE: [text]go=[elapsedtime][/text] [math show=f]last=0[/math] [loop start=1&end=99999] [commitdatabase theCopy.db] [waitforfile file=thisFileWillNeverExist&timeout=10][/waitforfile] [search db=theCopy.db&eqixdatarq=[blank]&rank=off&max=500] [replacefounditems]ix=[math]last=last+1[/math][/replacefounditems] [showif [numfound]=0][break][/showif] [/search] [/loop] Processing took [math]([elapsedtime]-[go])/60[/math] seconds. This code will process 500 records at a time, wait 10 seconds before processing the next batch of 500 records, and stop automatically when it has processed every record in the db. The timeout is there to limit the amount of resources consumed by this thread while it is processing the db. It should allow plenty of time for other threads to do their work without causing the server to grind to a halt. When processing is done, just replace the original db with this one. Then in your append contexts use "autonumber=ix" so new records will have incremental values. And when you want to sort in reverse db order use "deixsort=1&ixtype=num". NOTES: 1- You may want to run this code with [loop start=1&end=1] first to see if it works. If it does, you'll also have to ... 2- Change the zero in "[math show=f]last=0[/math]" to the largest number in the "ix" field (otherwise you'll get duplicates with "ix" values of 1-500) ... then use [loop start=1&end=99999] before you run the code again. Regards, Kenneth Grome WebDNA Solutions http://www.webdnasolutions.com Web Database Systems and Linux Server Management Kenneth Grome

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:

Beta 18 (1997) Emailer and encryption (1997) maximum characters in [username]? (2002) [ot] Any One Want A WebDNA Billing Program? (2003) Separate SSL Server (1997) Bug Report, maybe (1997) Unique SKUs (2000) Nested tags count question (1997) Stats (2004) WebCat2 several catalogs? (1997) URL encoding (1998) WebCat2b14MacPlugIn - [include] doesn't hide the search string (1997) sorting and grouping (1998) PCS Frames (1997) Setting up shop (1997) webcat license???? (1997) Multiple Domains with 1 Shopping Cart (2008) Cart Transfer from Un-Secure to Secure (2000) Help! Missing [showif] or [hideif] (2000) [Fwd: Rotating Banners ... (was LinkExchange)] (1997)