简体   繁体   中英

Is it possible to call stored procedure in view?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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