An issue about create a function in Stored Procedures
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!
Subject
Views
Written By
Posted
An issue about create a function in Stored Procedures
1958
April 08, 2014 12:52AM
925
April 08, 2014 11:35AM
1034
April 09, 2014 05:43AM
920
April 09, 2014 01:29PM
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.