Mysql 如何调用一个存储过程,将另一个存储过程的结果作为参数传递?

Mysql 如何调用一个存储过程,将另一个存储过程的结果作为参数传递?,mysql,stored-procedures,Mysql,Stored Procedures,在伪代码中,这正是我想要实现的: MAIN STORED PROCEDURE ids = CALL GetListOfIds(_user) FOREACH (id in ids) CALL AnotherStoredProcedure(id) 这个问题的答案在我的这篇文章中得到了部分或大部分的回答(我相信在我之前的其他人也是如此)。伪代码如下(使用伪代码并添加一点) 主存储过程(又称主存储过程) 选择B1: 选择B2: (Always and I me

在伪代码中,这正是我想要实现的:

MAIN STORED PROCEDURE

    ids = CALL GetListOfIds(_user) 

    FOREACH (id in ids) 
        CALL AnotherStoredProcedure(id)

这个问题的答案在我的这篇文章中得到了部分或大部分的回答(我相信在我之前的其他人也是如此)。伪代码如下(使用伪代码并添加一点)

主存储过程(又称主存储过程)

选择B1:

选择B2:

(Always and I mean always more performant, but not always possible):
Figure out the necessary sql calls to Update with a Join Pattern
or work thru other steps necessary without a cursor to arrive at 
your destination. Which may include the creation of other 
temporary tables or the use of permanent work tables (session-based 
or not), depending on concurrency issues (other users doing the 
same thing at the same time)

请注意,如果您是唯一有机会在上述情况发生时随时使用上述表格的人,或者说维护程序,那么会话和会话的概念就不适用了。在这种情况下,您只需自由使用表,因为不存在并发问题。至少在那些工作表中。

这个问题的答案在我的这本书中部分或大部分得到了回答(我相信在我之前的其他人也会回答)。伪代码如下(使用伪代码并添加一点)

主存储过程(又称主存储过程)

选择B1:

选择B2:

(Always and I mean always more performant, but not always possible):
Figure out the necessary sql calls to Update with a Join Pattern
or work thru other steps necessary without a cursor to arrive at 
your destination. Which may include the creation of other 
temporary tables or the use of permanent work tables (session-based 
or not), depending on concurrency issues (other users doing the 
same thing at the same time)

请注意,如果您是唯一有机会在上述情况发生时随时使用上述表格的人,或者说维护程序,那么会话和会话的概念就不适用了。在这种情况下,您只需自由使用表,因为不存在并发问题。至少对于那些工作表。

我相信我前面的回答会有所帮助,但您要做的是调用第一个表,填充另一个表(不需要是临时表,它可以是基于会话的永久表,就像在会话中一样,返回OUT参数)。然后,包装存储过程使用整个表的数据或为您分割的特定于会话的数据(其中包含会话的列),如果是多用户并发的,如果我向数据库中添加新视图会怎么样?对不起,我的意思是,如果复制其他存储过程代码并在主存储过程中执行查询,会怎么样?然后我可以重复这些结果吗?你问题下的第一条评论说明了你通常可以做什么。这是行的。这些行可以在临时表或永久表中。如果您不是在谈论行,则使用OUT参数。这就是这些答案的目的(不是小评论框):我相信我前面的答案会有所帮助,但您要做的是调用第一个答案,填充另一个表(不需要是临时表,它可以是基于会话的永久表,就像在会话中一样,以OUT参数返回)。然后,包装存储过程使用整个表的数据或为您分割的特定于会话的数据(其中包含会话的列),如果是多用户并发的,如果我向数据库中添加新视图会怎么样?对不起,我的意思是,如果复制其他存储过程代码并在主存储过程中执行查询,会怎么样?然后我可以重复这些结果吗?你问题下的第一条评论说明了你通常可以做什么。这是行的。这些行可以在临时表或永久表中。如果您不是在谈论行,则使用OUT参数。这就是这些答案的目的(不是小评论框):p
(Always and I mean always more performant, but not always possible):
Figure out the necessary sql calls to Update with a Join Pattern
or work thru other steps necessary without a cursor to arrive at 
your destination. Which may include the creation of other 
temporary tables or the use of permanent work tables (session-based 
or not), depending on concurrency issues (other users doing the 
same thing at the same time)