4 Replies - 8507 Views - Last Post: 22 July 2011 - 06:22 AM Rate Topic: ***-- 2 Votes

#1 Sandippatel.nvs   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 17-July 11

How to subtract no. of sold item from database 'stock' table t

Posted 21 July 2011 - 11:25 AM

Hi i am new to java, i am developing a POS application. I am using two database table (1)Stock- for maintaining the purchase and sell product transactions (2)Sold_product-- to keep the record of sold product.

Please help me, how can i subtract the number of sold item from the table of Stock

i.e Stock of coke bottle is 25, when manager sold 2 bottles out of them then the stock of coke deduced to 25-2=23 dynamically.
Is This A Good Question/Topic? 0
  • +

Replies To: How to subtract no. of sold item from database 'stock' table t

#2 CasiOo   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1578
  • View blog
  • Posts: 3,551
  • Joined: 05-April 11

Re: How to subtract no. of sold item from database 'stock' table t

Posted 21 July 2011 - 12:33 PM

It depends on how you have made your database table.

You could use an UPDATE PreparedStatement, and update the number of coke bottles in your database if that's how you have made it.
Was This Post Helpful? 0
  • +
  • -

#3 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: How to subtract no. of sold item from database 'stock' table t

Posted 21 July 2011 - 10:04 PM

first select the row that contains your part number from your inventory database
subtract 1 from the quantity column
update that row with the new quantity
Was This Post Helpful? 0
  • +
  • -

#4 Sandippatel.nvs   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 17-July 11

Re: How to subtract no. of sold item from database 'stock' table t

Posted 22 July 2011 - 01:21 AM

View Postpbl, on 21 July 2011 - 10:04 PM, said:

first select the row that contains your part number from your inventory database
subtract 1 from the quantity column
update that row with the new quantity


Thank you, sir
But how can i use select statement in java
Was This Post Helpful? 0
  • +
  • -

#5 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: How to subtract no. of sold item from database 'stock' table t

Posted 22 July 2011 - 06:22 AM

Take a look into JDBC, specifically the PreparedStatement class which was mentioned above.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1