我在 MySQL 5.5.22-Ubuntu 上创建了一个过程,在我的测试中它应该返回四行,但它没有返回任何内容。我已经读过返回结果集会很困难,我尝试了一些方法,但都没有奏效(作为选择...进入@result...)。另外,我试图从程序中运行选择,它正在返回,但是当我运行程序时,它什么也不返回。有人可以帮助我吗?
请参阅下面我的程序代码:
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 ;
我尝试使用以下命令调用它:
CALL getCurrentAndNextScheduleItem(1,4);
任何提示将不胜感激。
提前致谢!