Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 17th, 2008, 09:50 AM
Registered User
 
Join Date: Oct 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Transaction advice - placing order on a ecomm site

I am in the process of creating a ecommerce solution for a small business. The site will need to take into consideration concurrency issues. I have used SQL Server before but never taken advantage of its Transaction handling. I will really be extremely grateful to anyone who can help with advice and suggestions on whether I am on the right track.

I have two tables to hold order information.
Orders - holds generic order details
  Customer Details (email, name etc)
  Order Value Details (subtotal, tax, discounts, shipping etc)
  Shipping Details (address info)
  Billing Details (probably not needed as I will be used a payment gateway such as HSBC or PayPal)
OrderItems - holds details of each of the items that make up the order
  Order - associated order record
  Stock - associated stock record
  Title - short product desc
  UnitPrice - price per stock item
  Quantity - number of these items ordered

I need to write a single proc which will place this order, creating the order record, adding each order item - checking stock levels etc.

My proposed logic to this proc is:

-- steps:
    -- 1. create order record - set status to OrderBeingPlaced (OrderStatusID = 5)
    -- 2. create temp table for holding order items (order items details are passed in a comma-delimted string)
    -- 3. populate temp table
    -- foreach item in temp table
    -- 3. lock stock record for this orderitem
    -- 4. check stock levels (rollback, unlock stock records and return if stock cant satisfy quantity being ordered)
    -- 5. add order items ()
    -- 6. update stock levels (rollback, unlock stock records and return if stock cant satisfy quantity being ordered)
    -- 7. update status to OrderPlaced - commit and return new order id


WEBSITE TRYS TO TAKE PAYMENT (using payment processor)
        -- if successful update status to PaymentRecieved
        -- if unsuccessful need to call another proc to delete order record, delete order item records and release the stock

As a precaution I will also be creating a sql job (scheduled to run every day at some specific time) to check whether there are any Orders with status OrderPlaced for longer than x hours and if so again delete order record, delete order items and release stock.

Let me know if there is any information you need to help me.

Thanks for taking the time to read this.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Why is IE placing the image up into the H1? mishagos BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 December 7th, 2006 10:32 AM
Placing Session variable KamalRaturi ASP.NET 2.0 Professional 3 September 13th, 2006 04:53 AM
It adds a new support to the eComm site subhasis.chakraborty ASP.NET 1.x and 2.0 Application Design 1 July 14th, 2005 03:46 PM
error in placing mysql.h jl_joanne Visual C++ 3 February 18th, 2005 07:09 PM
Placing quotes in attributes rooroo Classic ASP Basics 2 December 1st, 2003 01:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.