我正在学习如何在MySQL中创建存储过程,并且在创建存储过程时遇到错误。
这是我的存储过程:
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetCategoryWiseProducts`(IN param varchar(250), IN isAll boolean)
BEGIN
declare catName VARCHAR(250) default '';
declare catId VARCHAR(250) default 0;
IF(isAll) THEN
SELECT 'All Products' as category_name, COUNT(*) as total from product_mast;
ELSE
SELECT category_name INTO catName, category_id INTO catId from category_mast WHERE slug = param;
SELECT catName as category_name, COUNT(*) as total from product_mast WHERE category_id = @category_id;
END IF;
END;
在else语句的第一个查询中获得错误from is not valid at this position, expecting : ';'
。
谢谢
答案 0 :(得分:1)
使用pi@Harald:~ $ java -version
openjdk version "9-Raspbian"
OpenJDK Runtime Environment (build 9-Raspbian+0-9b181-4bpo9rpt1)
OpenJDK Server VM (build 9-Raspbian+0-9b181-4bpo9rpt1, mixed mode)
,请参见24.1 Defining Stored Programs:
pi@Harald:~ $ javac -version
javac 9-Raspbian
DELIMITER
变量集的值在哪里?
答案 1 :(得分:1)
选择语法为SELECT id,数据INTO @ x,@ y FROM test.t1 LIMIT 1;参见https://dev.mysql.com/doc/refman/8.0/en/select-into.html