Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incorrect parameters in the call to native function 'concat'

Tags:

sql

mysql

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'

Any idea how to resolve this.

I am using MYSQL workbench for running sql queries

SQL script generated by MYSQL workbench is as follows

 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 ;
like image 988
atulya Avatar asked May 20 '14 08:05

atulya


1 Answers

You are missing a comma after tablName:

 set @cmd = concat('Create table', tablName, ' as ( select name from   samprojects.projects  where type=''',projName, ''')');
like image 133
Patrick Hofman Avatar answered Oct 14 '22 06:10

Patrick Hofman