CREATE PROCEDURE spResultSet1 
  DYNAMIC RESULT SETS 1
BEGIN
  DECLARE cur1 CURSOR WITH RETURN FOR
    SELECT 'A', 'A1' FROM src LIMIT 3;
  OPEN cur1;
END;  
  
CREATE PROCEDURE spResultSet2
  DYNAMIC RESULT SETS 2
BEGIN
  DECLARE cur1 CURSOR WITH RETURN FOR
    SELECT 'B', 'B1' FROM src LIMIT 5;
  DECLARE cur2 CURSOR WITH RETURN FOR
    SELECT 'C', 'C1' FROM src LIMIT 7;
  OPEN cur1;
  OPEN cur2;
END;

DECLARE v1 VARCHAR(10);
DECLARE v2 VARCHAR(10);

CALL spResultSet1;
ALLOCATE c1 CURSOR FOR PROCEDURE spResultSet1;

FETCH c1 INTO v1, v2;
WHILE (SQLCODE = 0)
DO
  PRINT v1 || ' - ' || v2;
  FETCH c1 INTO v1, v2;
END WHILE;
CLOSE c1;

CALL spResultSet2;
ALLOCATE c2 CURSOR FOR PROCEDURE spResultSet2;

FETCH c2 INTO v1, v2;
WHILE (SQLCODE = 0)
DO
  PRINT v1 || ' - ' || v2;
  FETCH c2 INTO v1, v2;
END WHILE;
CLOSE c2;

ALLOCATE c3 CURSOR FOR PROCEDURE spResultSet2;

FETCH c3 INTO v1, v2;
WHILE (SQLCODE = 0)
DO
  PRINT v1 || ' - ' || v2;
  FETCH c3 INTO v1, v2;
END WHILE;
CLOSE c3;
