J'ai créé une procédure sur MySQL 5.5.22-Ubuntu, et sur mon test il devrait retourner quatre lignes mais il ne retourne rien. J'ai déjà lu qu'il serait difficile de retourner un resultset et j'ai essayé quelques approches mais aucune n'a fonctionné (comme select ... dans @result ...). En outre, j'ai essayé d'exécuter la sélection hors de la procédure, et il revient, mais quand je exécute la procédure, il ne renvoie rien. Quelqu'un pourrait-il m'aider s'il vous plaît?MySQL - procédure stockée ne renvoyant pas resultset
Voir ci-dessous mon code de procédure:
DELIMITER $$
DROP PROCEDURE IF EXISTS `switchboard3b-scheduler`.`getCurrentAndNextScheduleItem`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `getCurrentAndNextScheduleItem`(IN screenId int, IN scheduleId int
-- , OUT cursorScheduleItems int
)
BEGIN
-- select current item
-- declare cursorScheduleItems cursor for
(SELECT "CURRENT_ITEM" as "ITEM", si.id,si.start_time,si.end_time, si.play_through, c.filename,ct.command
FROM schedule_item si JOIN channel_content cc ON si.channel_content_id = cc.id
JOIN content c ON cc.content_id = c.id
JOIN content_type ct ON c.content_type_id = ct.id
WHERE si.channel_screen_id = @screenId
AND si.schedule_id = @scheduleId
AND (si.day=0 OR si.day=DAYOFWEEK(DATE(NOW())))
AND si.start_time <= NOW()
AND si.end_time > NOW()
ORDER BY si.day DESC, si.start_time DESC LIMIT 1)
-- select next item for that day
UNION ALL
(SELECT "NEXT_ITEM_TODAY" as "ITEM", si.id,si.start_time,si.end_time, si.play_through, c.filename,ct.command
FROM schedule_item si JOIN channel_content cc ON si.channel_content_id = cc.id
JOIN content c ON cc.content_id = c.id
JOIN content_type ct ON c.content_type_id = ct.id
WHERE si.channel_screen_id = @screenId
AND si.schedule_id = @scheduleId
AND (si.day=0 OR si.day=DAYOFWEEK(DATE(NOW())))
AND si.start_time > NOW()
ORDER BY si.day DESC, si.start_time ASC LIMIT 1)
-- select first two items of the next day
UNION ALL
(SELECT "NEXT_ITEMS_TOMORROW" as "ITEM", si.id,si.start_time,si.end_time, si.play_through, c.filename,ct.command
FROM schedule_item si JOIN channel_content cc ON si.channel_content_id = cc.id
JOIN content c ON cc.content_id = c.id
JOIN content_type ct ON c.content_type_id = ct.id
WHERE si.channel_screen_id = @screenId
AND si.schedule_id = @scheduleId
AND (si.day=0 OR si.day=DAYOFWEEK(DATE(NOW()+1)))
ORDER BY si.day DESC,si.start_time ASC LIMIT 2);
-- CLOSE cursorScheduleItems;
END $$
DELIMITER ;
J'ai essayé de l'appeler avec la commande:
CALL getCurrentAndNextScheduleItem(1,4);
Toute pointe serait appréciée.
Merci d'avance!
Je suis en train de retourner un jeu de résultats. –