0

I am using python to make a connection with the mySql database and run a procedure. In the procedure, there are two select statements that return the result. I am using the following code to execute procedure

query = "Call procedure_name()"
cursor.execute(query)
procedureResult = cursor.fetchall();

but this returns the only result of the first select statement. How can I get the result of second select?

procedure

DELIMITER $$

USE `my_database`$$

DROP PROCEDURE IF EXISTS `dim_get_orders`$$

CREATE DEFINER=`root`@`%` PROCEDURE `dim_get_orders`()
 BEGIN
SELECT 'hi';

SELECT 'hello';
END$$

DELIMITER ;
5
  • 1
    Show us your procedure (or an example of it) Commented May 29, 2015 at 9:33
  • @Sir_FZ edited my question with procedure Commented May 29, 2015 at 10:41
  • You're getting the result of the second select? Commented May 29, 2015 at 10:44
  • This seems like what you need to fix in your procedure: stackoverflow.com/questions/20317971/… Commented May 29, 2015 at 10:50
  • but in my case first select may have multiple records/rows Commented May 29, 2015 at 12:40

1 Answer 1

-1

Read the "DB API 2.0 Specifications" on cursor objects. According to it, a stored procedure call can have a nextset() method to get a second query.

I have not used cur.nextset() on a MySQL server. But it works.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.