我在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 ;
答案 0 :(得分:1)
啊终于解决了。选择列中另一个名为fnUserGetChildrenProfileCount的函数是罪魁祸首,因为它也调用了fnGetProfileAlbumsPhotoCount()函数,并且该调用只有一个参数,即缺少第二个参数。