I am trying to call a user defined stored procedure from a select statement and its giving me an error. However when I call a system procedure it works just fine. Is there a way to call a user defined procedure from a select statement. This is for mysql
SELECT ID, email FROM user PROCEDURE simpleproc();
give me an error ERROR 1106 (42000): Unknown procedure 'simpleproc'
mysql> call simpleproc();
Query OK, 0 rows affected (0.21 sec)
where as
SELECT ID, email FROM user PROCEDURE ANALYSE();
works
解决方案
You can call stored procedure from select statement,To call a procedure you must use following syntax:
CALL stored_procedure_name (param1, param2, ....)
Such as, you can CALL following procedure:
DELIMITER //
CREATE PROCEDURE `procedure1`(IN var1 INT)
BEGIN
SELECT var1 + 2 AS result;
END//
as
CALL procedure1(10);