What is the equivalent of Oracle’s REF CURSOR in MySQL?

懵懂的女人 提交于 2019-12-02 13:33:25

There is no analog of REF CURSOR in MySQL. Stored procedures and functions allow to pass and return only scalar datata types, see the reference here - CREATE PROCEDURE and CREATE FUNCTION Syntax.

MySQL cannot operate with arrays. A workaround is to use a table (or TEMPORARY TABLE).

Also - take advantage of visual object editors and stored procedure debugger in dbForge Studio for MySQL.

Pavan Ebbadi

MySQL doesn't have a refcursor like Oracle. If you are planning to write a stored procedure that returns multiple rows/result set in MySQL just do

DROP procedure IF EXISTS `sample`;
DELIMITER $$
CREATE  PROCEDURE `sample`(p_rank IN INT)
BEGIN
select * from MyTable where id=p_rank;
END$$
DELIMITER ;

and call sample();. It will return a result set which you can use.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!