How to travers query results and then call the other Stored Procedure in MySQL Stored Procedure?

106 views Asked by At

Now I can write the separate stored procedure.

-- get the total query id result
select id from book where bookprice>10;
-- only pass a single id
call sp_refreshbook(id); 

How to merge them together?now I want to search the id result and them call the sp_refreshbook in each id in the result in a new store stored procedure.

1

There are 1 answers

0
flower On BEST ANSWER

I have solve this problem using cursor by myself.

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;