Reputation:
This is my stored procedure.
CREATE DEFINER=`root`@`localhost` PROCEDURE `getGameIdByPlayerAndDate`(out id integer)
BEGIN
-- DECLARE myCursor CURSOR FOR
select game
from `playerstatistic`, `game`
where `playerstatistic`.`game`=`game`.`id`
and `date`="2014-03-26"
and `PlayerName`="Kenneth Faried";
-- open myCursor;
-- FETCH myCursor INTO id;
-- set id=0;
-- SELECT id;
-- SET id=2;
-- SELECT id;
END
I wanted to pass player name and date, and the procedure returns the game id. But now for trouble shooting, I hard coded the player name and date.
I call the procedure, it selects the correct data.
Then I add playerName
parameter to the procedure, and add a dummy argument to the call statement. The store procedure selects nothing now!
Do I write anything wrong? How to make the code work?
Upvotes: 0
Views: 45
Reputation: 4284
You must assign the value passed as parameter:
First, change the name to avoid duplicate names:
CREATE PROCEDURE `getGameIdByPlayerAndDate`(IN p_playerName varchar(40),out id integer)
Now assign this parameter to PlayerName field
`PlayerName` = p_playerName;
Upvotes: 0