Gendaful Gendaful - 27 days ago 8
MySQL Question

How to return a resultset from StoredProcedure using MySql?

I am writing a stored procedure using MySql which returns multiple rows using select statement.

My code is as below

drop procedure if exists GetAccounts;
DELIMITER //
CREATE PROCEDURE GetAccounts()
BEGIN
DECLARE rowcount int;
SET @resultset = (SELECT * from requests where STATUS = "FAILURE" ;
END //
DELIMITER


Any examples of how to return a resultSet in storedProcedure?

Thanks
Gendaful

Answer
DROP PROCEDURE IF EXISTS GetAccounts; 
DELIMITER // 
CREATE PROCEDURE GetAccounts() 
BEGIN 
DECLARE rowcount int;
    SELECT * from requests where STATUS = "FAILURE" ;
END // 
DELIMITER ;