2011-01-22 68 views
1

我得到在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

回答

1

啊終於解決了這個問題。另一個在select列中調用fnUserGetChildrenProfileCount的函數是罪魁禍首,因爲它也調用了fnGetProfileAlbumsPhotoCount()函數,THAT調用只有一個參數,即錯過了第二個參數。