简体   繁体   English

MySQL-存储过程不返回结果集

[英]MySQL - stored procedure not returning resultset

I created a procedure on MySQL 5.5.22-Ubuntu, and on my test it should return four rows but it is not returning anything. 我在MySQL 5.5.22-Ubuntu上创建了一个过程,并在我的测试中应返回四行,但未返回任何内容。 I already read it would be difficult to return a resultset and I tried a few approaches but none worked (as select... into @result...). 我已经读过,很难返回一个结果集,我尝试了几种方法,但是都没有用(将select转换为@result ...)。 Also, I tried to run the select out of the procedure, and it is returning, but when I run through the procedure, it just doesn't return anything. 另外,我尝试从过程中运行选择,并且它正在返回,但是当我运行过程时,它什么都没有返回。 Could anyone please assist me? 谁能帮我吗?

See below my procedure code: 见下面我的程序代码:

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 ;

I tried to call it with the command: 我试图用命令调用它:

CALL getCurrentAndNextScheduleItem(1,4);

Any tip would be appreciated. 任何提示将不胜感激。

Thanks in advance! 提前致谢!

What are you trying to return? 您想返回什么? its type is not mentioned in the create procedure. 创建过程中未提及其类型。

可能是您的“输出”参数带有注释-

-- , OUT cursorScheduleItems int

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 存储过程返回计算结果集 - stored procedure returning a calculated resultset 如何将结果添加到 MySQL 存储过程的结果集中? - How to add results to the resultset of a MySQL stored procedure? mysql asp.net从存储过程返回多行结果集 - mysql asp.net returning multiple rows resultset from stored procedure 从mysql存储过程中的mysql结果集中获取最后一个结果 - Get the last result from the mysql resultset in mysql stored procedure 从Rails 3调用MySQL存储过程(返回结果集)时出错 - Error while invoking MySQL Stored procedure(that returns resultset) from Rails 3 如何通过使用带有“ select”关键字的MySql存储过程来遍历ResultSet? - How to iterate over ResultSet by using MySql Stored Procedure with “select” keyword? MYSQL错误#2014:结果集为空时在存储过程中 - MYSQL Error #2014: in stored procedure when resultset is empty 如何总是从MySQL存储过程返回空结果集? - How return empty resultset always from MySQL stored procedure? 使用 SELECT 的结果集...用于更新 MySQL 存储过程 - Use ResultSet of SELECT...FOR UPDATE in MySQL Stored Procedure MySQL存储过程,如果存储过程的Resultset为空,则更改一个变量并再次运行 - MySQL stored procedure, if Resultset from stored procedure is empty then change one variable and run again
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM