aspose file tools*
The moose likes JDBC and the fly likes Decreasing numbers in SQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Decreasing numbers in SQL " Watch "Decreasing numbers in SQL " New topic
Author

Decreasing numbers in SQL

shuzo monsoon
Ranch Hand

Joined: Feb 11, 2004
Posts: 54
Hello! What I'm trying to do at the moment is have a query which finds the appropriate record of a particulat product in the STOCK table and then decrement that quantity by 1. However, I'm not sure ntirely how to do this, as I know how to change the number by specifying one but I'm not sure how to minus the number. I tried this :

But this doesn't work because the second QuantityInStock is not recognised. Has anyone any ideas?
Thanks!
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
If the STCOK table has a column called "QuantityInStock" then you can do this:


Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
eammon bannon
Ranch Hand

Joined: Mar 16, 2004
Posts: 140

But this doesn't work because the second QuantityInStock is not recognised
[/qoute]
Can you explain what you mean by this? Are you getting a SQLException, or is the variable undefined? It looks like it should work fine to me, though you appear to probably be using a SQL varchar datatype for QuantityInStock, despite treating it as numeric.
shuzo monsoon
Ranch Hand

Joined: Feb 11, 2004
Posts: 54
Thanks Blake! That worked. Thanks!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Decreasing numbers in SQL