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
精彩评论