简体   繁体   English

无法在 MySql 5.7 中创建程序

[英]Cant create procedure in MySql 5.7

I'm racking my head, I can't figure out what the problem is.我绞尽脑汁,我无法弄清楚问题是什么。 This SQL code does not work on MySQL 5.7此 SQL 代码不适用于 MySQL 5.7

CREATE  PROCEDURE sp_create_message (queue_name VARCHAR(50), data TEXT)
DETERMINISTIC
BEGIN
    SET @stm = CONCAT('
        INSERT INTO queue_', queue_name, '
            (data)
        VALUES
            (?)
    ');
    PREPARE stm FROM @stm;
    EXECUTE stm USING data;
    DEALLOCATE PREPARE stm;
END //

#1064 - You have an error in the request. #1064 - 您的请求有误。 Check the documentation for the MySQL version you are using for the correct syntax about " on line 4检查您正在使用的 MySQL 版本的文档,了解第 4 行关于 " 的正确语法

i dont now whats the problem.我现在不知道是什么问题。

Rather than use the value directly from an input parameter,the USING clause in the EXECUTE statement only accept user variables. EXECUTE 语句中的 USING 子句不直接使用来自输入参数的值,而是只接受用户变量。 Try modify the code like this:尝试像这样修改代码:

set @data=data;
EXECUTE stm USING @data;

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

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