Re: Updating Integer value in DB

This WebDNA talk-list message is from

2007


It keeps the original formatting.
numero = 68683
interpreted = N
texte = Ki Song wrote: > Really quick question. I am trying to create a call to a products.db to > update a quantity on an inventory item so that, for example, if the value > that is in the db currently is 2, and I wanted to add 1 to the quantity, how > would I accomplish this? > > I wrote the following replace command, but it doesn't seem to work: > > [replace db=^inventory.db&wqSKUdatarq=[SKU]]ON HAND=[MATH]ON > HAND+[updatevalue][/MATH][/replace] > > updatevalue = an integer, positive or negative, that is used to change the > ON HAND. > > For example: > SKU= test > ON HAND= 3 > updatevalue= 45 > > After this replace is done, ON HAND should = 48. Couple of other points to go with the good points that have been said. You *can* use "On_Hand" without the brackets as long it is a *math variable* and it is inside a math context. I am guessing you are grabbing this value from the database *before* the replace context is used?.. so it depends on how you are initializing the variable (math or text) weather you need the brackets. If I were you, once you get a replace context that you think should work, but doesn't. troubleshoot it by taking out the first and last brackets to see exactly what values are being input into the replace context: replace db=^inventory.db&eqSKUdatarq=[url][SKU][/url]]ON_HAND=[MATH]ON_HAND+[updatevalue][/MATH][/replace Lastly, along with what Matthew was talking about, "[math]" doesn't like to see blank values, and will break if that happens. A trick to getting around this, if you think there is a chance for a blank value, is to put a 0 before the questionable value/s..: ON_HAND=[math]0[ON_HAND]+0[updatevalue][/math] Donovan -- =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o DONOVAN D. BROOKE EUCA Design Center <- Web Development (specializing in eCommerce),-> <- Desktop Publishing, Print Consulting, Labels -> <-Glass Products, off-hand Classes/studio rental-> PH:> (608) 835-2476 | Forum:> http://egg.bz/forum/ Web Sites:> http://www.euca.us & http://www.egg.bz =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o ------------------------------------------------------------- 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://webdna.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: Updating Integer value in DB ( Stuart Tremain 2007)
  2. Re: Updating Integer value in DB ( Matthew A Perosi 2007)
  3. Re: Updating Integer value in DB ( Donovan Brooke 2007)
  4. Re: Updating Integer value in DB ( "Dan Strong" 2007)
  5. Re: Updating Integer value in DB ( Matthew A Perosi 2007)
  6. Re: Updating Integer value in DB ( Ki Song 2007)
  7. Re: Updating Integer value in DB ( Jim Ziegler 2007)
  8. Re: Updating Integer value in DB ( Matthew A Perosi 2007)
  9. Updating Integer value in DB ( Ki Song 2007)
Ki Song wrote: > Really quick question. I am trying to create a call to a products.db to > update a quantity on an inventory item so that, for example, if the value > that is in the db currently is 2, and I wanted to add 1 to the quantity, how > would I accomplish this? > > I wrote the following replace command, but it doesn't seem to work: > > [replace db=^inventory.db&wqSKUdatarq=[SKU]]ON HAND=[math]ON > HAND+[updatevalue][/MATH][/replace] > > updatevalue = an integer, positive or negative, that is used to change the > ON HAND. > > For example: > SKU= test > ON HAND= 3 > updatevalue= 45 > > After this replace is done, ON HAND should = 48. Couple of other points to go with the good points that have been said. You *can* use "On_Hand" without the brackets as long it is a *math variable* and it is inside a math context. I am guessing you are grabbing this value from the database *before* the replace context is used?.. so it depends on how you are initializing the variable (math or text) weather you need the brackets. If I were you, once you get a replace context that you think should work, but doesn't. troubleshoot it by taking out the first and last brackets to see exactly what values are being input into the replace context: replace db=^inventory.db&eqSKUdatarq=[url][SKU][/url]]ON_HAND=[math]ON_HAND+[updatevalue][/MATH][/replace Lastly, along with what Matthew was talking about, "[math]" doesn't like to see blank values, and will break if that happens. A trick to getting around this, if you think there is a chance for a blank value, is to put a 0 before the questionable value/s..: ON_HAND=[math]0[ON_HAND]+0[updatevalue][/math] Donovan -- =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o DONOVAN D. BROOKE EUCA Design Center <- Web Development (specializing in eCommerce),-> <- Desktop Publishing, Print Consulting, Labels -> <-Glass Products, off-hand Classes/studio rental-> PH:> (608) 835-2476 | Forum:> http://egg.bz/forum/ Web Sites:> http://www.euca.us & http://www.egg.bz =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o ------------------------------------------------------------- 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://webdna.smithmicro.com/ Donovan Brooke

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:

WebCatalog for guestbook ? (1997) Help formatting search results w/ table (1997) Frames and WebCat (1997) Frames and WebCat (1997) Looking for WebDNA calendar (2004) More Applescript (1997) Secure server question (1997) Word search (1997) expired beta (1997) taxrate - off by 1 cent (1997) Running 2 two WebCatalog.acgi's (1996) Why is my easy [AddLineItems] NOT working?? (2000) [WebDNA] reply vs. new (2009) Blog/social networking shortcut (2007) can WC render sites out? (1997) Problems passing [SKU] with $Replace in 2.0 (1997) Getting total number of items ordered (1997) Showif for mulitple variations (1997) WebCat2b13MacPlugIn - [include] (1997) I forgot (1998)