简体   繁体   中英

How to get stored procedure result set to other stored procedure. Or return table in function in MySQL

My first stored procedure returns 3 values which I will use in another stored procedure. I tried like this:

CREATE DEFINER=`db`@`%` PROCEDURE `SP_Expense`(
    flightInstanceId INT 
)
begin
    SELECT F.BaseFare, CALL SP_Orderdetail(F.fareId)  
    FROM fare;
end$$

but I'm getting a syntax error.

Is it possible in functions? Which is return table ?

You cant call a stored procedure from with in a select statement. What you are doing is trying to call a function. Create Fucntion . If I understand your question SP_Orderdetail(F.fareId) returns a table? I wonder if you could turn SP_Orderdetail(F.fareId) into a view instead?

This might help as well: Create Stored procedure and Create function syntax

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM