MySQL Forums
Forum List  »  Stored Procedures

Creating a stored routine from within a stored procedure
Posted by: Davide Cicuta
Date: February 19, 2013 08:13AM

Hello!
I have a string (TEXT) which contains something like:

DELIMITER $$
DROP PROCEDURE IF EXISTS someProcedure $$
CREATE PROCEDURE someProcedure(
someParam bigint(20),
OUT someOtherParam varchar(64))
someProcedure:BEGIN

-- something

END$$
DELIMITER ;


The string correctly drops someProcedure, then creates it. No problems on its own.

I need to execute the same DDL (or at least an adapted version) from within a stored procedure, to create ANY stored procedure at runtime. I tried loading it (as it is, including delimeters and everything) into a global variable and then using

PREPARE statement FROM @query;
EXECUTE statement;
DEALLOCATE PREPARE statement;

The result is Error Code 1064 "You have an error in your SQL syntax..."
The same query works if run directly.

I imagined there was something about delimiters, but I have tried several combinations, without success, so maybe it's worse than that... Can anyone help me please?

Options: ReplyQuote


Subject
Views
Written By
Posted
Creating a stored routine from within a stored procedure
1994
February 19, 2013 08:13AM


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.