Can anyone help me understand why when I run the following:
DELIMITER //
CREATE FUNCTION dbo.Profit (P_ProductID int, P_VendorID int, P_SellPrice decimal (12,4))
RETURNS decimal (12,4)
DETERMINISTIC
BEGIN
DECLARE p_profit decimal (12,4)
SET p_profit = P_SellPrice - Cost FROM VendorProduct
WHERE ProductID = P_ProductID AND VendorID = P_VendorID
RETURN p_profit
END //
DELIMITER;
I am getting the error: "[ERROR in query 1] 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 'SET p_profit = P_SellPrice - Cost FROM VendorProduct WHERE ProductID = P_Produc' at line 6 Execution stopped!"
I am using Sequel Pro, currently, and just trying to learn how to create functions.