gpt4 book ai didi

mysql - 求助 MySQL incorrect number of arguments function 错误

转载 作者:行者123 更新时间:2023-11-29 00:58:45 26 4
gpt4 key购买 nike

我在 MySQL 中遇到一个错误,这让我抓狂,我就是想不通到底出了什么问题。我进行以下调用:

CALL ProfileUpdateProgress(107)

MySQL 返回错误:“FUNCTION ccms.fnGetProfileAlbumsPhotoCount 的参数数量不正确;预期为 2,得到 1

现在,正如您在下面的代码中看到的,对该函数的调用是:fnGetProfileAlbumsPhotoCount(_profileId, profileUserId)

这是两个论点,不是吗?为什么会报错??我要疯了!!

数据库进程:

DELIMITER $$

DROP PROCEDURE IF EXISTS `ProfileUpdateProgress` $$
CREATE DEFINER=`root`@`%` PROCEDURE `ProfileUpdateProgress`(
IN _profileId integer
)
BEGIN

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

CALL ProfileUpdateProfileProgress(_profileId);

END $$

DELIMITER ;

依次调用:

DELIMITER $$

DROP PROCEDURE IF EXISTS `ProfileUpdateProfileProgress` $$
CREATE DEFINER=`root`@`%` PROCEDURE `ProfileUpdateProfileProgress`(IN _profileId int)
BEGIN

-- Declarations here

SELECT profileEyes, profileSex, profileHair, profileBustBand, profileBustCup, profileBirthCountry, profileProfession , profileAbout,
profileBiography, fnGetProfilePhoto(_profileId, null) AS profilePhoto, fnGetProfileAlbumsPhotoCount(_profileId, profileUserId) AS albumPhotoCount,
userAllowMultipleProfiles, profileIsPrimary, fnUserGetChildrenProfileCount(userId) AS ownerProfileCount
INTO _profileEyes, _profileSex, _profileHair, _profileBustBand, _profileBustCup, _profileBirthCountry, _profileProfession,
_profileAbout, _profileBiography, _profilePhoto, _albumPhotoCount, _userAllowMultipleProfiles, _profileIsPrimary,
_ownerProfileCount
FROM profile
INNER JOIN user
ON profileUserId = userId
WHERE profileId = _profileId;


-- Other irrelevant code here


END $$

DELIMITER ;

被调用的错误函数如下所示:

DELIMITER $$

DROP FUNCTION IF EXISTS `fnGetProfileAlbumsPhotoCount` $$
CREATE DEFINER=`root`@`%` FUNCTION `fnGetProfileAlbumsPhotoCount`(
_profileId int,
_userId int
) RETURNS int(11)
BEGIN

DECLARE outProfileAlbumsPhotoCount int DEFAULT 0;

-- Irrelvant Code

RETURN outProfileAlbumsPhotoCount;

END $$

DELIMITER ;

最佳答案

啊终于解决了。选择列中另一个名为 fnUserGetChildrenProfileCount 的函数是罪魁祸首,因为它也调用了 fnGetProfileAlbumsPhotoCount() 函数,而该调用只有一个参数,即缺少第二个参数。

关于mysql - 求助 MySQL incorrect number of arguments function 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4767035/

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