The Artima Developer Community
Sponsored Link

Web Buzz Forum
Need some stored procedure feedback

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Josh Baltzell

Posts: 664
Nickname: jbaltzell
Registered: Nov, 2003

Josh Baltzell is an ASP.NET and ASP Programmer learning all he can about all.
Need some stored procedure feedback Posted: Oct 6, 2004 9:17 AM
Reply to this message Reply

This post originated from an RSS feed registered with Web Buzz by Josh Baltzell.
Original Post: Need some stored procedure feedback
Feed Title: ShortDomainName.com
Feed URL: http://www.contegix.com/Rss.aspx
Feed Description: Weblog of Josh Baltzell. Focusing on the computer industry and .NET programming related news. I like to get involved on the discussions wherever they are.
Latest Web Buzz Posts
Latest Web Buzz Posts by Josh Baltzell
Latest Posts From ShortDomainName.com

Advertisement

I have been using Stored Procedures in my .NET apps for a while now because I like the idea of limiting the rights of the SQL user to only what I want it to have.  Plus if there happens to be a performance increase then all the better.  But... not being a SQL expert I doubt myself on the quality of my procedures.  Could anyone out there that finds this give me some critique on whether or not I am using stored procedures in the best way possible?  Below are a few examples of what I am using.

A:

CREATE Procedure VI_CartSubmitOrder
(
 @OrderID int,
 @PaymentReferenceID varchar(20),
 @BalanceChange money,
 @UserID int
)
AS
BEGIN
 UPDATE    OrderMain
 SET              Submitted = 1, DateSubmitted = GETDATE(), PaymentReferenceID = @PaymentReferenceID
 WHERE     (OrderID = @OrderID)
END
 UPDATE    iX_UserData
 SET       Custom06 = Custom06 - @BalanceChange
 WHERE     (LogonID = @UserID)
GO

 

B:

CREATE Procedure VI_CatalogGetDetails
(
    @ProductID int
)
As
SELECT 
    Products.ProductID,Products.ProductTitle,Products.Cost,Products.DescShort,Products.DescLong,Products.ImageFull,Products.ImageLarge,Products.ImageCatalog,Products.Variable
FROM   
    Products
GROUP BY   
    Products.ProductID,Products.ProductTitle,Products.Cost,Products.DescShort,Products.DescLong,Products.ImageFull,Products.ImageLarge,Products.ImageCatalog,Products.Variable
HAVING 
    Products.ProductID = @ProductID

GO

 

C:

CREATE Procedure VI_CartTotalPrice
(
    @OrderID    int,
    @TotalCost money OUTPUT
)
AS
SELECT     @TotalCost = SUM(Products.Cost * OrderItems.Quantity)
FROM         OrderItems INNER JOIN
                      Products ON OrderItems.ProductID = Products.ProductID INNER JOIN
                      OrderMain ON OrderItems.OrderID = OrderMain.OrderID
WHERE     (OrderMain.OrderID = @OrderID)

GO

 

D:

CREATE Procedure VI_CartAddItem
 @OrderID int,
 @ProductID int,
 @Quantity int,
 @intOrderItemID int OUTPUT
 
AS
 
BEGIN
 INSERT INTO OrderItems
  (
   OrderID,
   Quantity,
   ProductID,
   DateTime,
   ShippingID
  )
  VALUES
  (
   @OrderID,
   @Quantity,
   @ProductID,
   GETDATE(),
   0
  )
 SELECT @intOrderItemID = @@IDENTITY
END
return @intOrderItemID

GO

Read: Need some stored procedure feedback

Topic: 1a verkn�pften Audio-Inhalten 11 Previous Topic   Next Topic Topic: Half-Life 2 RC, could be out in a few weeks

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use