gpt4 book ai didi

Mysql错误: Not allowed to return a result set from a function

转载 作者:行者123 更新时间:2023-11-29 08:31:23 28 4
gpt4 key购买 nike

我正在尝试对更新语句的参数进行有条件的更改。当我尝试以下功能时出现以下错误

/home/y/bin/mysql -u root < testpri.sql > out
ERROR 1415 (0A000) at line 4: Not allowed to return a result set from a function

testpri.sql内容如下:

use `zestdb`;
DROP FUNCTION IF EXISTS UPDATEPASSWD;
DELIMITER //
CREATE FUNCTION UPDATEPASSWD(n INT) RETURNS varchar(255) DETERMINISTIC
BEGIN
DECLARE mypasswd varchar(255);
IF (n = 1) THEN
SET mypasswd = '12ccc1e5c3c9203af7752f937fca4ea6263f07a5';
SELECT 'n is 1' AS ' ';
ELSE
SET mypasswd = '1a7bc371cc108075cf8115918547c3019bf97e5d';
SELECT 'n is 0' AS ' ';
END IF;>
SELECT CONCAT('mypasswd is ', mypasswd) AS ' ';
RETURN mypasswd;
END //
DELIMITER ;
CALL UPDATEPASSWD(0);

我错过了什么?

最佳答案

我认为这实际上是您的调试 SELECT 调用。

来自docs :

Statements that return a result set can be used within a stored procedure but not within a stored function. This prohibition includes SELECT statements that do not have an INTO var_list clause...

关于Mysql错误: Not allowed to return a result set from a function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16492225/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com