无法在select上运行mysql语法

问题描述 投票:0回答:1

我试着在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 database syntax
1个回答
0
投票

你的定界符在这里有各种问题。请看 使用存储程序 在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 ;
© www.soinside.com 2019 - 2024. All rights reserved.