gpt4 book ai didi

mysql - 错误 1064 (42000) : SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ');

转载 作者:行者123 更新时间:2023-11-29 10:14:40 32 4
gpt4 key购买 nike

我正在尝试编写一个 mysql 函数...但我收到语法错误为

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ');

我的代码如下,

delimiter //
CREATE FUNCTION calculateNetItemStandardDiscountAmount(productId INT,quantity INT) RETURNS DOUBLE
BEGIN
DECLARE discountPer DOUBLE;
DECLARE unitPrice DOUBLE;
DECLARE netItemDiscountAmount DOUBLE;
DECLARE netItemAmount DOUBLE;

SELECT `SellingUnitPrice` into unitPrice
FROM `TBL_PRODUCT_MASTER`
WHERE `Id` = productId;
SET netItemAmount = quantity * unitPrice ;
insert into debugtable select concat('ACTUAL AMOUNT ', netItemAmount);

SELECT discDetail.`DiscountPercentage` into discountPer
FROM `TBL_DISCOUNT_DETAIL` AS discDetail , `TBL_DISCOUNT` AS disc, TBL_PRODUCT_DISCOUNT AS prodDisc
WHERE disc.`DiscountStartDate` < NOW()
AND disc.`DiscountEndDate` > NOW()
AND disc.`SchemeType` = 'AMOUNT'
AND discDetail.DiscountId = disc.Id
AND prodDisc.productId = productId
AND prodDisc.discountId = disc.Id
AND prodDisc.`IsEnabled` = 1
AND disc.`IsEnabled` = 1
AND (quantity * unitPrice) >= discDetail.LowerLimit and (quantity * unitPrice) <= discDetail.HigherLimit);

insert into debugtable select concat('STD DISCOUNT PER BY AMOUNT ', discountPer);
IF (discountPer IS NOT NULL) THEN
SET netItemDiscountAmount = ((netItemAmount) * (discountPer * 0.01));
insert into debugtable select concat('APPLY VOLUME DISCOUNT ', netItemDiscountAmount);
END IF;

SELECT discDetail.`DiscountPercentage` into discountPer
FROM `TBL_DISCOUNT_DETAIL` AS discDetail , `TBL_DISCOUNT` AS disc, TBL_PRODUCT_DISCOUNT AS prodDisc
WHERE disc.`DiscountStartDate` < NOW()
AND disc.`DiscountEndDate` > NOW()
AND disc.`SchemeType` = 'VOLUME'
AND discDetail.DiscountId = disc.Id AND prodDisc.productId = productId
AND prodDisc.discountId = disc.Id
AND prodDisc.`IsEnabled` = 1
AND disc.`IsEnabled` = 1
AND (Quantity >= discDetail.LowerLimit and Quantity <= discDetail.HigherLimit);

insert into debugtable select concat('STD DISCOUNT PER BY VOLUME ', discountPer);
IF (discountPer IS NOT NULL) THEN
SET netItemDiscountAmount = netItemDiscountAmount + ((netItemAmount) * (discountPer * 0.01));
insert into debugtable select concat('APPLY AMOUNT DISCOUNT ', netItemDiscountAmount);
END IF;

RETURN netItemDiscountAmount;
END//
delimiter ;

任何帮助将不胜感激...提前致谢...

最佳答案

看起来此行末尾有未打开的括号

SELECT discDetail.`DiscountPercentage` into discountPer FROM `TBL_DISCOUNT_DETAIL` AS discDetail , `TBL_DISCOUNT` AS disc, TBL_PRODUCT_DISCOUNT AS prodDisc WHERE disc.`DiscountStartDate` < NOW() AND disc.`DiscountEndDate` > NOW() AND disc.`SchemeType` = 'AMOUNT' AND discDetail.DiscountId = disc.Id AND prodDisc.productId = productId AND prodDisc.discountId = disc.Id AND prodDisc.`IsEnabled` = 1 AND disc.`IsEnabled` = 1 AND (quantity * unitPrice) >= discDetail.LowerLimit and (quantity * unitPrice) <= discDetail.HigherLimit)

关于mysql - 错误 1064 (42000) : SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ');,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50291760/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com