成功创建后,我尝试更改存储过程。
DELIMITER $$
ALTER PROCEDURE `purchaseItem`(
IN productID INT,
IN quantity INT,
IN memID INT,
OUT stat INT)
BEGIN
DECLARE qnty INT;
DECLARE price decimal(10,2);
DECLARE description VARCHAR(500);
SET qnty = (SELECT p_Unit FROM product WHERE p_ID = productID);
IF qnty >= quantity && qnty != 0 THEN
SELECT p_Price INTO price FROM product WHERE p_ID = productID;
SELECT p_Desc INTO description FROM product WHERE p_ID = productID;
INSERT INTO purchase VALUES
(NULL, productID, quantity, price, description , memID, 0, NULL);
UPDATE product
SET p_Unit = (qnty - quantity)
WHERE p_ID = productID;
SET stat = 0;
ELSE
SET stat = 1;
END IF;
END$$
DELIMITER ;
但是,在尝试更改 SP 时出现以下错误。
#1064 - 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 '( IN productID INT, IN quantity INT, IN memID INT, ' at line 1
有人可以指出我在哪里做错了。谢谢!