Re: SKU lookup
This WebDNA talk-list message is from 1997
It keeps the original formatting.
numero = 13100
interpreted = N
texte = At 12:38 AM 8/21/97, you wrote:>Hello>>Hey how would one write an expression to lookup the last SKU entry made>in a given db, and then add 1 to it, and enter that automatically in the>SKU field?>-- As Ken mentions, the [cart] is great for generating unique skus. However,sometimes you might require a unique sku which is not a random number suchas 8721054256023 which is the sort of number you get by using [cart].For example, what if you are making an employee database and you want totrack it using a logical progression (1, 2, 3 etc.) with each newemployee's number being one higher than the last.Here is a snippet of code to take the highest sku value from a database andthen increment it by one:[search db=yourdatabase.db&grskudata=0&skusort=1][founditems][name][math]newsku=[sku][/math][/founditems][/search][math]newsku=(newsku+1)[/math]
Final value=[math]newsku[/math]
To hide the output from a [math][/math] context just enclose it like soThis lets the code get parsed without displaying the results.To call the newsku value elsewhere in the template just use[math]newsku[/math].....................................................................W O R L D P O I N T I N T E R A C T I V E DANIEL CAMERON web engineerHonolulu San Francisco 2800 woodlawn drive 222 sutter street dcameron@worldpoint.com suite 170 sixth floor www.worldpoint.com honolulu, hi 96822 san francisco, ca 94108 voice.808.539.3932 fax.808.539.3943 cell.808.291.1610.....................................................................
Associated Messages, from the most recent to the oldest:
At 12:38 AM 8/21/97, you wrote:>Hello>>Hey how would one write an expression to lookup the last SKU entry made>in a given db, and then add 1 to it, and enter that automatically in the>SKU field?>-- As Ken mentions, the
[cart] is great for generating unique skus. However,sometimes you might require a unique sku which is not a random number suchas 8721054256023 which is the sort of number you get by using
[cart].For example, what if you are making an employee database and you want totrack it using a logical progression (1, 2, 3 etc.) with each newemployee's number being one higher than the last.Here is a snippet of code to take the highest sku value from a database andthen increment it by one:[search db=yourdatabase.db&grskudata=0&skusort=1]
[founditems][name]
[math]newsku=[sku][/math][/founditems][/search]
[math]newsku=(newsku+1)[/math]
Final value=[math]newsku[/math]
To hide the output from a
[math][/math] context just enclose it like so[math]newsku=[sku][/math]>This lets the code get parsed without displaying the results.To call the newsku value elsewhere in the template just use
[math]newsku[/math].....................................................................W O R L D P O I N T I N T E R A C T I V E DANIEL CAMERON web engineerHonolulu San Francisco 2800 woodlawn drive 222 sutter street dcameron@worldpoint.com suite 170 sixth floor www.worldpoint.com honolulu, hi 96822 san francisco, ca 94108 voice.808.539.3932 fax.808.539.3943 cell.808.291.1610.....................................................................
Daniel Cameron
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:
Newbie problem blah blah blah (1997)
Customer login feature (2004)
Not really WebCat (1997)
RE: Adding headers to email (1997)
Sandbox DB permissions (2005)
WebCatalog NT beta 18 now available (1997)
Spiders and Bots (2000)
using showpage and showcart commands (1996)
WebCat2b15MacPlugin - showing [math] (1997)
international time (1997)
Separate SSL Server (1997)
Re:Dumb Question about Docs (1997)
Forms Search Questions (1997)
AppleScript/.db (was:FTP to WebStar) (2001)
hidden databases (2000)
NT version and O'reily's WebSite (1997)
Migrating to NT (1997)
RE: Answer: WebDelivery downloads alias, not original ? (1997)
using showpage and showcart commands (1996)
Multiple Pulldowns (1997)