MySQL Forums
Forum List  »  Stored Procedures

Creating new schema inside the Procedure
Posted by: Nikhil VK
Date: November 09, 2012 02:48AM

I need to create a schema inside the Procedure with the schema name passed as a parameter of the Procedure. I have tried the following script but no success;

mysql> delimiter $$
create procedure test2(name varchar(10))
BEGIN
SET @var = CONCAT('CREATE SCHEMA IF NOT EXISTS ',name);
PREPARE stmt FROM @var;
EXECUTE stmt;
END$$
delimiter ;

mysql> call test2('tessting');
ERROR 1295 (HY000): This command is not supported in the prepared statement protocol yet



I have tried the following script also

mysql> delimiter $$
create procedure test1(name varchar(10))
BEGIN
SET @var =name;
CREATE SCHEMA IF NOT EXISTS @var ;
END$$
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'CREAT
E SCHEMA IF NOT EXISTS @var ;
END' at line 4


Is it not possible to create the schema inside the procedure or am i missing something here?

Options: ReplyQuote


Subject
Views
Written By
Posted
Creating new schema inside the Procedure
3298
November 09, 2012 02:48AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.