Reputation: 11688
this is my stored procedure:
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
for some reason the query:
/* 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;
return the Expires as null all the time.
When i'm running the same query outside of the procedure - it returns the Expires as a value...
I can't understand what is wrong...
Upvotes: 0
Views: 908
Reputation: 11688
Ok found it, You must provide different names to variables and fields.
my expires is identical to Expires in the table, therefor it is always null.
Upvotes: 1