Bug #46481 Declare a cursor for stored procedure results
Submitted: 30 Jul 2009 16:34 Modified: 31 Jul 2009 5:58
Reporter: Valery Kuznetsov Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S4 (Feature request)
Version:5.0 OS:Windows (XP)
Assigned to: CPU Architecture:Any

[30 Jul 2009 16:34] Valery Kuznetsov
Description:
Inside stored procedure, I would like to declare cursor to result set from other stored procedure.

Forum thread: http://forums.mysql.com/read.php?98,266799,266799#msg-266799

How to repeat:
Here is the sample:

CREATE PROCEDURE `Results` (val INT)
BEGIN
SELECT * FROM customer WHERE id=val;
END

CREATE PROCEDURE `Calc` (val INT)
BEGIN
resultset = CALL Results(1);
//Here I would like to read result set.
END

Suggested fix:
something like this:

CREATE PROCEDURE `Calc` (val INT)
BEGIN
DECLARE cur CURSOR FOR CALL Results(1);
END
[30 Jul 2009 16:58] Valeriy Kravchuk
Although syntax you suggest is different, I think this is actually a duplicate of bug #31716 or even older bug #10817. Please, check.
[31 Jul 2009 5:58] Valeriy Kravchuk
So, this is a duplicate of bug #10817.