简体   繁体   English

存储过程查询中的错误

[英]Error in stored procedure query

I am getting following error in stored procedure as: 我在存储过程中遇到以下错误:

DELIMITER $$
DROP PROCEDURE IF EXISTS `comm_pay_intro`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `comm_pay_intro`(IN `id` VARCHAR(20),IN 
`comm_type` VARCHAR(50))
BEGIN
DECLARE i INTEGER;
 DECLARE userid varchar(20);
 DECLARE rateid int(10);
 DECLARE levels int(1);
 DECLARE idx INTEGER;
DECLARE curs1 CURSOR FOR (SELECT `id` , `user_id`
 FROM `temp_table` order by `id`);
OPEN curs1;
FETCH curs1 INTO idx,userid;
Select `level_id` into rateid , `levels` into levels FROM `user_levels`
 INNER JOIN `commission_type` ON `type_id`=`Commission_Type` WHERE 
`Commission_Type`=comm_type and `levels`=idx
order by `levels`;
   insert into user_commission(rate_id, user_id) 
VALUES(rateid,userid); 
CLOSE curs1;
END$$
DELIMITER ;

Error: 错误:

You have an error in your SQL syntax; 您的SQL语法有误; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'into levels FROM user_levels INNER JOIN commission_type ON type_id =`Comm' at line 13 检查与您的MariaDB服务器版本相对应的手册以获取正确的语法,以在第13行的'into level FROM user_levels INNER JOIN commission_type ON type_id =`Comm'附近使用

Change that SELECT .. INTO statement like below. 如下更改该SELECT .. INTO语句。 Also, your variable name levels is same as column name; 另外,您的变量名levels与列名相同; which may cause issue. 这可能会导致问题。 Refrain from naming your variable like that. 不要这样命名您的变量。

Select `level_id`, `levels` into rateid , levels FROM `user_levels`

See Documentation for more information on same. 有关更多信息,请参见文档

像这样

 Select `level_id`,`levels` into rateid  levels FROM `user_levels`

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM