DELIMITER //
CREATE FUNCTION total_cost_for_customer (
custNumber INT
)
RETURNS INT
DETERMINISTIC
READS SQL DATA
BEGIN
DECLARE total INT;
SELECT SUM(unitPrice)
INTO total
FROM OrderLine
WHERE orderNo IN (
SELECT orderNo
FROM FoodOrder
WHERE custNo = custNumber
);
RETURN total;
END //
DELIMITER ;
SQL Error [1064] [42000]: (conn=18) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 8
Line 8 would be the DECLARE statement.


DELIMITER //?