这是我的存储过程:

CREATE DEFINER=`root`@`localhost` PROCEDURE `isUserValid`(IN `facebookId` VARCHAR(20), IN `userAccessToken` TEXT)
    NO SQL
    COMMENT 'check if user is valid. return true or false'
Begin
    /* declare the select resluts variables*/
    Declare accessToken TEXT;
    Declare expires datetime;

    /* fill the variables with saved user's access token an expires time*/
    Select Access_Token, Expires
    Into accessToken, expires
    From Users Where Facebook_Id = facebookId;

    select expires,accessToken;
    /* If the saved access token and expires are valid return true */
    If (BINARY accessToken = userAccessToken And expires > now()) Then
        select true As isUserValid;
    Else
        select false As isUserValid;
    End If;
End


由于某种原因,查询:

/* fill the variables with saved user's access token an expires time*/
Select Access_Token, Expires
Into accessToken, expires
From Users Where Facebook_Id = facebookId;


始终将Expires返回为null。

当我在过程外运行相同的查询时-它返回Expires作为值...

我不明白怎么了...

最佳答案

好的找到了
您必须为变量和字段提供不同的名称。

我的expires与表中的Expires相同,因此它始终为null。

10-08 18:21