2015-06-12 256 views
0

現在我可以編寫單獨的存儲過程。如何遍歷查詢結果,然後在MySQL存儲過程中調用另一個存儲過程?

-- 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的結果在一家新店的存儲過程。

+0

告訴我們'sp_refreshbook'小狗,我們可以創建一個新的sp_refreshbookLooper – Drew

回答

0

我已經用光標自己解決了這個問題。

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; 
相關問題