繁体   English   中英

从mysql存储过程中选择

[英]Select from mysql stored procedure

由于不能这样做,所以:

select * from (call my_stored_procedure(params));

上述声明还有其他选择吗?

一个过程可以返回多个结果集,每个结果集都有自己的模式。 它不适用于SELECT语句。

用户定义的功能可能是一个选项。 这是一个例子:

CREATE FUNCTION CubicVolume
 -- Input dimensions in centimeters
 (@CubeLength decimal(4,1), @CubeWidth decimal(4,1),@CubeHeight decimal(4,1) )
  RETURNS decimal(12,3) -- Cubic Centimeters.
  AS
  BEGIN
   RETURN ( @CubeLength * @CubeWidth * @CubeHeight )
 END

有关此链接的更多信息: http : //msdn.microsoft.com/zh-cn/library/aa175085%28SQL.80%29.aspx

创建一个临时表变量并将sp值插入其中,例如:

Declare @t table
(
  --column numbers will be equals to the numbers return by SP
)
Insert Into @t
call my_stored_procedure(params)

Select * From @t

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM