Stored procedure design

  • I've got some general questions about stored procedures and how people use them in their applications.

    For example, let's say you have an order entry application, and you've got the tables: Customer, Order, OrderLine.

    Imagine you want to create a Customer record: would you have a CreateCustomer proc that performed an Insert into Customer or perhaps a CreateCustomer proc that called a general InsertCustomerRecord proc?  The idea behind the second approach being that there would be only one place where a Customer record was Inserted, but you may have multiple procs that call that InsertCustomerRecord proc.

    Is there a right or wrong way to go about doing this?  Anyone care to share how they structure stored procs with regards to this sort of thing?

  • What would the difference between the CreateCustomer proc and the InsertCustomerRecord proc?

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • I might have separate insert procs for each table and then an overall "uspCustomerAdd" that might call a couple of these to ensure a complete customer record is being inserted. I wouldn't have two procs that inserted into the same table without there being some major difference in the logic.

  • That's the approach I was thinking made most sense.  Thanks for the response 🙂

     

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply