Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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 July 18th, 2003, 12:18 PM
Authorized User
 
Join Date: Jun 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Trying to add a GetTaxAmount Stored Procedure

Hello,

Thanks in advance for whoever can help me. The following code is a stored procedure I am trying to get to work to add tax for CA residents. I can't get it working. Can someone please help?

-------------------------------------------
ALTER PROCEDURE GetTaxAmount
(@CartID varchar(50),
@CustomerID varchar(50))
AS

Declare @Amount Money
Declare @Tax Money
Declare @State varchar

Select @Amount = SUM(Product.[Price]*ShoppingCart.Quantity)
From ShoppingCart
INNER JOIN Product
ON ShoppingCart.ProductID = Product.ProductID
WHERE ShoppingCart.CartID = @CartID

Select @State = Customer.State
From Customer
Where CustomerID = @CustomerID

Select @Tax = @Amount*0.0825

If @State = CA
    Return @Tax
Else
    Return 0


    Return
 
Old July 18th, 2003, 12:31 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

What error do you get? What exactly is the problem?

One thing that I can see is that CA is not enclosed in quotes. Change the last part to this:

Code:
If @State = 'CA'
    Return @Tax
Else
    Return 0
    If that doesn't fix it, please be more specific.

Regards,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old July 18th, 2003, 02:56 PM
Authorized User
 
Join Date: Jun 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for the help. i did that and it compiled. however, it is always returning 0. what can i do?
 
Old July 18th, 2003, 03:12 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I think you'll need to change the code that does the state lookup to this:

SELECT @State = (SELECT Customer.State From Customer Where CustomerID = @CustomerID)

You may also need to check if this statement returns a value. Maybe there is no customer with an ID of @CustomerID.....

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Add new Table to Stored Procedure pallone SQL Server 2000 2 February 14th, 2007 12:58 PM
stored procedure keyvanjan Classic ASP Basics 6 August 1st, 2006 07:42 AM
stored procedure kdm260 SQL Server 2000 2 June 19th, 2006 04:45 PM
stored procedure keyvanjan Classic ASP Basics 2 May 26th, 2006 01:16 AM
How to add a stored procedure in Access badgolfer Access 2 June 17th, 2004 08:13 PM





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