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 November 4th, 2004, 02:29 PM
Registered User
 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Stored Procedure Syntax Problem

I am a beginning user of sql server and I keep getting a syntax error at my else statements. The following is the code I have been using. Please help me out
Thank You

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

CREATE PROC dbo. SP_AccessorialCharges AS

--Created by Max Gay
--November 4, 2004


--Declare variables

DECLARE @Notification BIT, @InsideDel BIT, @LiftGate BIT, @ResidentialDel
BIT, @HazMat BIT, @DropCharge BIT, @CompanyNumber BIGINT, @CarrierNumber
BIGINT, @Weight BIGINT, @AccChrg MONEY, @AccChrgTot MONEY, @Exception8
VARCHAR, @Exception5 VARCHAR, @Exception6 VARCHAR, @displayError INT


--Actual work

SELECT * FROM dbo.[Carrier Profiles] WHERE ([Carrier Number]=82) AND
([Company Number]=7)

--Display error codes and set exceptions

BEGIN
IF @Notification= 1
    IF [Notification] = 'No Service'
        IF @Exception8 = 'Update'
     SET @displayError = '1'
    SET @AccChrg = CAST (@Exception5 AS MONEY)
END

ELSE
BEGIN
    SET @AccChrg = @AccChrg + [Notification]
END

--Inside Delivery

BEGIN
IF @InsideDel= 1
IF [Inside delivery CWT] = 'No Service'
    SET @displayError = 2
END

ELSE
BEGIN
    SET @AccChrg = @AccChrg + [Inside delivery CWT] * (@Weight/100)
END

BEGIN
    IF @AccChrg < [Inside delivery MIN]
        SET @AccChrg = [Inside delivery MIN]

    IF @AccChrg < [Lift Gate MIN]
        SET @AccChrg = [Lift Gate MIN]

    IF @AccChrg < [Residential del MIN]
        SET @AccChrg = [Residential del MIN]

END

ELSE
BEGIN
    IF @AccChrg > [Inside delivery MAX]
        SET @AccChrg = [Inside delivery MAX]

    IF @AccChrg > [Lift Gate MAX]
        SET @AccChrg = [Lift Gate MAX]

    IF @AccChrg > [Residential del MAX]
        SET @AccChrg = [Residential del MAX]
END

--Lift Gate

BEGIN
    IF @LiftGate= 1
    IF [Lift Gate CWT] = 'No Service'
        SET @displayError = 3
END

ELSE
BEGIN
    SET @AccChrg = @AccChrg + [Lift Gate CWT] * (@Weight/100)
END

--Residential Delivery

BEGIN
    IF @ResidentialDel = 1
    IF [Residential del CWT] = 'No Service'
        SET @displayError = 4
END

ELSE
BEGIN
    SET @AccChrg = @AccChrg + ([Residential del CWT]) * (@Weight/100)
END




--Haz Mat

BEGIN
    IF @HazMat = 1
    IF [Haz Mat] = 'No Service'
    IF @Exception8 = 'Update'
        SET @displayError = 5
        SET @AccChrg =CAST (@Exception6 AS MONEY)
END

--Drop Charge

BEGIN
    IF @DropCharge = 1
    IF [Drop Charge] = 'No Service'
        SET @displayError = 6
END

--Total accessorial charges

BEGIN
    SET @AccChrgTot=@AccChrg
END





RETURN
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

Max
 
Old November 4th, 2004, 05:16 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

You don't seem to assign values to the variables just before this.
Code:
BEGIN
IF @Notification= 1
    IF [Notification] = 'No Service'
        IF @Exception8 = 'Update'
     SET @displayError = '1'
    SET @AccChrg = CAST (@Exception5  AS MONEY)
END
May be you can post the exact error that you see that. That should help us understand what it is.

Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
stored procedure problem keyvanjan ASP.NET 2.0 Professional 0 September 19th, 2007 06:28 AM
Problem with stored procedure analuz ADO.NET 1 July 18th, 2007 08:33 AM
Stored Procedure Call Syntax Bob Bedell VB.NET 2002/2003 Basics 1 March 26th, 2006 01:43 PM
Stored procedure problem dkspivey SQL Language 2 February 6th, 2006 01:44 PM
Stored Procedure Problem brettdavis4 ASP.NET 1.0 and 1.1 Basics 7 November 3rd, 2003 09:46 PM





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