英文:
Can I use prepare statement to create function and stored procedures in mysql?
问题
我需要通过准备和执行语句来创建一个新的函数和存储过程。是否可能?
准备语句如下:
DELIMITER ;;
CREATE FUNCTION `db_name`.`fn_name`(Params)
RETURNS varchar(50) CHARSET utf8mb4 DETERMINISTIC
BEGIN
DECLARE name varchar(50);
RETURN IFNULL(name,"");
END ;;
DELIMITER ;
执行语句。
英文:
I need to create a new function and stored procedures through the prepare and execute statement. Whether it is possible or not?
prepare statement from 'DELIMITER ;;
CREATE FUNCTION `db_name`.`fn_name`(Params)
RETURNS varchar(50) CHARSET utf8mb4 DETERMINISTIC
BEGIN
DECLARE name varchar(50);
RETURN IFNULL(name,"");
END ;;
DELIMITER ;';
execute statement;
答案1
得分: 2
不,这是不可能的。请参考准备语句中允许的 SQL 语法,了解准备语句中允许的语句列表。CREATE PROCEDURE
不在其中。
英文:
No, it's not possible. See SQL Syntax Permitted in Prepared Statements for the list of statements allowed in prepared statements. CREATE PROCEDURE
isn't one of them.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论