我在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);
任何提示都会受到赞赏。
提前致谢!
答案 0 :(得分:0)
你还想回来什么?创建过程中未提及其类型。
答案 1 :(得分:0)
可能是您的“out”参数被注释 -
-- , OUT cursorScheduleItems int