存储过程的错误行86

时间:2014-05-29 16:06:45

标签: stored-procedures

我试图让这个存储过程正常工作。我已经连续工作了一个月,昨晚一直工作到3点,我正在接近倦怠。我真的想让这个工作,因为我们有一个广告活动,我们花了数百个来发送流量。

USE [redhotkitties2005db]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[proc_rhkprod_lock_items_for_paypal]
    @cfuseridid bigint
    ,@transaction_guid uniqueidentifier = NULL
AS
BEGIN
    SET NOCOUNT ON;

    declare @tblcartID          bigint
            ,@cfuserid          bigint
            ,@tblproductsid     bigint
            ,@quantity          bigint
            ,@localInventoryID  varchar(100)
            ,@taxologykey       bigint
            ,@name              varchar(1000)
            ,@shortDescription  varchar(8000)
            ,@productDescription varchar(8000)
            ,@UorLorUL          varchar(2)
            ,@unitPrice         money
            ,@shippingWeight    numeric(6, 2)
            ,@overSize          tinyint
            ,@smallPic1         nvarchar(100)
            ,@largePic1         nvarchar(100)
            ,@smallPic2         nvarchar(100)
            ,@largePic2         nvarchar(100)
            ,@smallPic3         nvarchar(100)
            ,@largePic3         nvarchar(100)

    SET @transaction_guid = coalesce(@transaction_guid,newid())

    declare c1 cursor forward_only for

    select      rhkProd_tblCart.tablePK AS tblcartID
                ,rhkProd_tblProducts.productID as tblproductsid
                ,rhkProd_tblCart.quantity
                ,rhkProd_tblProducts.localInventoryID
                ,rhkProd_tblProducts.name
                ,rhkProd_tblProducts.taxologyKey
                ,rhkProd_tblProducts.shortDescription
                ,rhkProd_tblProducts.productDescription
                ,rhkProd_tblProducts.UorLorUL
                ,rhkProd_tblProducts.unitPrice
                ,rhkProd_tblProducts.shippingWeight
                ,rhkProd_tblProducts.overSize
                ,rhkProd_tblProducts.smallPic1
                ,rhkProd_tblProducts.largePic1
                ,rhkProd_tblProducts.smallPic2
                ,rhkProd_tblProducts.largePic2
                ,rhkProd_tblProducts.smallPic3
                ,rhkProd_tblProducts.largePic3
    from        rhkProd_tblCart
    INNER JOIN  rhkProd_tblProducts
    on          rhkProd_tblCart.tblProductsFK = rhkProd_tblProducts.productID
    where       rhkProd_tblCart = @cfuserid



    open c1

    fetch next
    from    c1
    into    @tblcartID
            ,@cfuserid
            ,@tblproductsid
            ,@quantity
            ,@localinventoryID
            ,@name
            ,@taxologykey
            ,@shortdescription
            ,@productdescription
            ,@UorLorUL
            ,@unitprice
            ,@shippingweight
            ,@oversize
            ,@smallpic1
            ,@largepic1
            ,@smallpic2
            ,@largepic2
            ,@smallpic3
            ,@largepic3
begin
    while @@fetch_status = 0

            insert into rhkprod_tblpaypallock (
                ,[cfuserid]
                ,[transaction_guid]
                ,[timestamp]
                ,[tblproductsFK]
                ,[quantity]
                ,[localInventoryID]
                ,[name]
                ,[taxologykey]
                ,[shortdescription]
                ,[productdescription]
                ,[uorlorul]
                ,[unitprice]
                ,[shippingweight]
                ,[oversize]
                ,[smallpic1]
                ,[largepic1]
                ,[smallpic2]
                ,[largepic2]
                ,[smallpic3]
                ,[largepic3]
            )
            values (
                ,@cfuserid
                ,@transaction_guid
                ,getdate()
                ,@tblproductsid
                ,@quantity
                ,@localinventoryID
                ,@name
                ,@taxologykey
                ,@shortdescription
                ,@productdescription
                ,@UorLorUL
                ,@unitprice
                ,@shippingweight
                ,@oversize
                ,@smallpic1
                ,@largepic1
                ,@smallpic2
                ,@largepic2
                ,@smallpic3
                ,@largepic3
            )

            update  rhkprod_tblproducts
            set     quantity = quantity - @quantity
            where   productid = @tblproductsid
            and     UorLorUL in ('U','L')

            fetch next
            from    c1
            into    @tblcartID
                    ,@cfuserid
                    ,@tblproductsid
                    ,@quantity
                    ,@localinventoryID
                    ,@name
                    ,@taxologykey
                    ,@shortdescription
                    ,@productdescription
                    ,@UorLorUL
                    ,@unitprice
                    ,@shippingweight
                    ,@oversize
                    ,@smallpic1
                    ,@largepic1
                    ,@smallpic2
                    ,@largepic2
                    ,@smallpic3
                    ,@largepic3

    close c1

    deallocate c1
end
END

1 个答案:

答案 0 :(得分:0)

您的INSERT语句在开头有一个逗号:

insert into rhkprod_tblpaypallock (
                ,[cfuserid]

应该是

insert into rhkprod_tblpaypallock (
                [cfuserid]

您的VALUES子句也有一个逗号:

values (
    ,@cfuserid

应该是

values (
    @cfuserid