开发者

Is it possible to call stored procedure in view?

开发者 https://www.devze.com 2023-03-01 10:46 出处:网络
A similar question about sql-server has开发者_如何学编程 been asked here. I\'m wondering if its possible in MySql.

A similar question about sql-server has开发者_如何学编程 been asked here. I'm wondering if its possible in MySql.

edit:

I want to use result set returned from procedure in view.


If you want to get result-set and use routine in FROM clause - NO. Stored routines (procedures or functions) in MySQL cannot return tables as result value.

But you can use functions as simple values, for example -

DELIMITER $$

CREATE FUNCTION mul10(Param1 INT)
RETURNS INT(11)
BEGIN
  RETURN Param1 * 10;
END
$$

DELIMITER ;

CREATE OR REPLACE VIEW view1
AS
SELECT mul10(2) AS column1;

SELECT column1 FROM view1;
----------
20
0

精彩评论

暂无评论...
验证码 换一张
取 消