Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 618
Gendaful Avatar asked Feb 18 '23 16:02

Gendaful


1 Answers

DROP PROCEDURE IF EXISTS GetAccounts; 
DELIMITER // 
CREATE PROCEDURE GetAccounts() 
BEGIN 
DECLARE rowcount int;
    SELECT * from requests where STATUS = "FAILURE" ;
END // 
DELIMITER ;
like image 54
felipsmartins Avatar answered Feb 21 '23 23:02

felipsmartins