Reputation: 5256
PostgreSQL allows you to define a function that returns a table. Does MySQL provide a similar feature? My research suggests not, but I'd be grateful if someone could show me otherwise.
Essentially, I want to add a "running-total" column to a rowset, and this is one of the options I'm investigating.
Upvotes: 0
Views: 2015
Reputation: 4972
You can not return a table using MySQL function, but you can using a stored procedure, I got something like this:
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Name`(OUT po_ErrMessage VARCHAR(200))
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
SET po_ErrMessage = 'Error in procedure sp_Name';
END;
SELECT * FROM table_name;
END
And for more information please refer to this link
Upvotes: 1