MySQLStored Procedure如何遍历查询结果然后调用另一个Stored Procedure?
How to travers query results and then call the other Stored Procedure in MySQL Stored Procedure?
现在我可以编写单独的存储过程了。
-- get the total query id result
select id from book where bookprice>10;
-- only pass a single id
call sp_refreshbook(id);
如何将它们合并在一起?现在我想搜索 id 结果,他们在新的存储过程中调用结果中每个 id 中的 sp_refreshbook
。
我自己用游标解决了这个问题
open v_result_cur;
repeat
fetch v_result_cur into v_id;
IF NOT v_done THEN
select v_id;
END IF;
until v_done end repeat;
close v_result_cur;
现在我可以编写单独的存储过程了。
-- get the total query id result
select id from book where bookprice>10;
-- only pass a single id
call sp_refreshbook(id);
如何将它们合并在一起?现在我想搜索 id 结果,他们在新的存储过程中调用结果中每个 id 中的 sp_refreshbook
。
我自己用游标解决了这个问题
open v_result_cur;
repeat
fetch v_result_cur into v_id;
IF NOT v_done THEN
select v_id;
END IF;
until v_done end repeat;
close v_result_cur;