ショッピング カート用に作成しようとしている次の準備済みステートメントがありますが、正しく実行されません。次のエラーが報告され、修正方法がわかりません。
#1064 - SQL 構文にエラーがあります。near '; を使用する正しい構文については、MySQL サーバーのバージョンに対応するマニュアルを確認してください。END $$' 25 行目
私の知る限り、IF ステートメントの構文は正しいですが、機能しません。
DELIMITER $$
CREATE PROCEDURE shopping_cart_add_product(IN inCartId CHAR(32),
IN inProductId INT, IN inAttributes VARCHAR(1000))
BEGIN
DECLARE productQuantity INT;
SELECT quantity
FROM shopping_cart
WHERE cart_id = inCartId
AND product_id = inProductId
AND attributes = inAttributes
INTO productQuantity;
IF productQuantity IS NULL THEN
INSERT INTO shopping_cart(cart_id, product_id, attributes,
productQuantityuantity, added_on)
VALUES (inCartId, inProductId, inAttributes, 1, NOW());
ELSE
UPDATE shopping_cart
SET quantity = quantity + 1, buy_now = true
WHERE cart_id = inCartId
AND product_id = inProductId
AND attributes = inAttributes;
ENDIF;
END $$