【问题标题】:How to travers query results and then call the other Stored Procedure in MySQL Stored Procedure?MySQL存储过程中如何遍历查询结果然后调用另一个存储过程?
【发布时间】:2015-08-27 21:56:24
【问题描述】:

现在我可以编写单独的存储过程了。

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

如何将它们合并在一起?现在我想搜索 id 结果,他们在新的 store 存储过程的结果中调用每个 id 中的 sp_refreshbook

【问题讨论】:

  • 告诉我们sp_refreshbook小狗,我们可以创建一个新的sp_refreshbookLooper

标签: mysql stored-procedures cursor mysql-workbench


【解决方案1】:

我自己用光标解决了这个问题。

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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-05
    • 1970-01-01
    • 1970-01-01
    • 2011-03-03
    • 1970-01-01
    • 1970-01-01
    • 2010-11-14
    相关资源
    最近更新 更多