Question: SQL Transaction Help: I have 4 SQL tables (noted in detail below). How can I create a SQL transaction that would create a new order,

SQL Transaction Help:

I have 4 SQL tables (noted in detail below). How can I create a SQL transaction that would create a new order, add a product to that order and then deduct the order quantity from the quantity on hand (QOH) - all to occur only if the quantity left over after the transaction would still be greater than zero?

Tables:

Product

  • SKU Int (auto-generating)
  • Product Name nchar
  • QOH int

Order

  • Order # - int (auto-generating)
  • Customer ID int

Customer

  • Customer ID int (auto-generating)
  • Customer Name nchar

OrderItem

  • Order Item ID int (auto-generating)
  • Order # - int
  • SKU int
  • Qty - int

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!