我试着在phpMyAdmin中运行这个。。。 结果发现有些不对劲。 我不知道这里出了什么问题。
DELIMITER ;
create definer=proiect_wd_user@localhost FUNCTION
f_suma(id_s int, price_f double,product_code_n char(255),quantity_b int)
returns double
BEGIN
select price_f into @price_f
from orders_details WHERE (id=id_s)
select quantity_b into @quantity_b
from orders_details WHERE (id=id_s)
set @suma_f=(@price_f*@quantity_b);
RETURN @suma_f;
end ;
Error:
MySQL said: Documentation
#1064 - 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 'select quantity_b into @quantity_b
from orders_details WHERE (id=id_s)
set @su' at line 7
这里的分隔符有各种问题。 请参见MySQL文档中的使用存储过程。
DROP FUNCTION IF EXISTS f_suma;
DELIMITER //
CREATE DEFINER=proiect_wd_user@localhost
FUNCTION f_suma(id_s int,price_f double,product_code_n char(255),quantity_b int)
RETURNS double
BEGIN
SELECT price_f INTO @price_f FROM orders_details WHERE (id=id_s);
SELECT quantity_b INTO @quantity_b FROM orders_details WHERE (id=id_s);
SET @suma_f=(@price_f*@quantity_b);
RETURN @suma_f;
END //
DELIMITER ;