MySQL 调用本机函数“concat”时参数不正确
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23754385/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Incorrect parameters in the call to native function 'concat'
提问by atulya
I am trying to create store procedure as follows
我正在尝试按如下方式创建存储过程
CREATE PROCEDURE `Test1` (IN projName VARCHAR(200), IN tablName VARCHAR(200))
BEGIN
set @cmd = concat('Create table', tablName ' as ( select name from samprojects.projects where type=',projName')');
PREPARE stmt FROM @cmd;
EXECUTE stmt;
END
And getting below error
并低于错误
ERROR 1583: Incorrect parameters in the call to native function 'concat'
错误 1583:调用本机函数“concat”时参数不正确
Any idea how to resolve this.
任何想法如何解决这个问题。
I am using MYSQL workbench for running sql queries
我正在使用 MYSQL 工作台来运行 sql 查询
SQL script generated by MYSQL workbench is as follows
MYSQL工作台生成的SQL脚本如下
USE `samprojects`;
DROP procedure IF EXISTS `Test1`;
DELIMITER $$
USE `samprojects`$$
CREATE PROCEDURE `Test1` (IN projName VARCHAR(200), IN tablName VARCHAR(200))
BEGIN
set @cmd = concat('Create table', tablName, ' as ( select name from samprojects.projects where type=',projName')');
PREPARE stmt FROM @cmd;
EXECUTE stmt;
END$$
DELIMITER ;
回答by Patrick Hofman
You are missing a comma after tablName
:
后面缺少一个逗号tablName
:
set @cmd = concat('Create table', tablName, ' as ( select name from samprojects.projects where type=''',projName, ''')');