帮助的参数不正确的MySQL号功能的错误

问题描述:

我得到在MySQL是推动我疯了,我只是无法弄清楚什么是错的错误。我让下面的调用:帮助的参数不正确的MySQL号功能的错误

CALL ProfileUpdateProgress(107) 

的MySQL返回错误:“为功能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

你能直接从MySQL客户端调用`fnGetProfileAlbumsPhotoCount`吗? – gregjor 2011-01-22 09:33:12

啊终于解决了这个问题。另一个在select列中调用fnUserGetChildrenProfileCount的函数是罪魁祸首,因为它也调用了fnGetProfileAlbumsPhotoCount()函数,THAT调用只有一个参数,即错过了第二个参数。