0

I am having trouble figuring out how to clear this error. Any help would be appreciated. Ray


DELIMITER //

CREATE FUNCTION discount_price
(item_id_param  varchar(10))
RETURNS DECIMAL(10, 2)
BEGIN
  DECLARE discount_price_var DECIMAL(10, 2);
    
  SELECT item_price - discount_amount
  INTO   discount_price_var
  FROM   order_items
  WHERE  item_id = item_id_param;
    
  RETURN discount_price_var;
END//
MRray
  • 1
  • I see no error here https://www.db-fiddle.com/f/cpStHNG9UStav37GzBH1ua/0 . Please post full code and full error – Ergest Basha May 26 '22 at 20:32
  • Here is the full error I am getting. 14:21:40 CREATE FUNCTION discount_price (item_id_param varchar(10)) RETURNS DECIMAL(10, 2) BEGIN DECLARE discount_price_var DECIMAL(10, 2); SELECT item_price - discount_amount INTO discount_price_var FROM order_items WHERE item_id = item_id_param; RETURN discount_price_var; END Error Code: 1418. This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable) 0.000 sec – MRray May 26 '22 at 21:21
  • 1
    Does this answer your question? [DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled](https://stackoverflow.com/questions/26015160/deterministic-no-sql-or-reads-sql-data-in-its-declaration-and-binary-logging-i) To others that cross this question, know that error is with MySQL 8. The first comment's link is set to v5.7, and does not error with this version. – Paul T. May 27 '22 at 01:04
  • Thanks Paul! That was driving mad and what you sent solved my problem. – MRray May 28 '22 at 00:14

0 Answers0