MySQL Forums
Forum List  »  Stored Procedures

An issue about create a function in Stored Procedures
Posted by: Jack Eingmarra
Date: April 08, 2014 12:52AM

Hello everyone:

I want to make a function in stored procedures as follows:

SET @update_stmt1320=CONCAT('CREATE FUNCTION ', db,".`getLearningCenterCategoryChildNodes`(rootId INT)
RETURNS varchar(1000)
BEGIN
DECLARE sTemp VARCHAR(1000);
DECLARE sTempChd VARCHAR(1000);

SET sTemp = '$';
SET sTempChd =cast(rootId as CHAR);

WHILE sTempChd is not null DO
SET sTemp = concat(sTemp,',',sTempChd);
SELECT group_concat(cid) INTO sTempChd FROM learning_center_category where FIND_IN_SET(parent_id, sTempChd)>0;
END WHILE;
RETURN sTemp;
END");
PREPARE stmt1320 FROM @update_stmt1320;
EXECUTE stmt1320;
DEALLOCATE PREPARE stmt1320;

It seems mysql prepare statement not support create function in stored procedures. But I really need to create function in stored procedures with user input database name.

So what can I do? Who can help me out?
Thanks in advance!

Options: ReplyQuote


Subject
Views
Written By
Posted
An issue about create a function in Stored Procedures
1955
April 08, 2014 12:52AM


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.