2
我試着去使用這個程序:MySQL的:調用存儲過程內部程序與返回值
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_login`(
IN in_Email VARCHAR(60),
IN in_Pass VARCHAR(45)
)
BEGIN
DECLARE d_UserType VARCHAR(45);
SET d_UserType := db.get_usertype((SELECT ID FROM User WHERE Email = in_Email));
IF (d_UserType = '1') THEN
SELECT * FROM User inner join tableA on tableA.ID = User.tableA_ID;
ELSEIF (d_UserType = '2') THEN
SELECT * FROM User inner join tableB on tableB.ID = User.tableB_ID;
ELSEIF (d_UserType = '3') THEN
SELECT * FROM User inner join tableC on tableC.ID = User.tableC_ID;
END IF;
END
,但我得到以下錯誤:錯誤1305(42000):功能db.get_usertype不存在。
的
CALL db.get_usertype((SELECT ID FROM User WHERE Email = '[email protected]'));
當我獨自一人測試工作正常。任何人都知道它爲什麼起作用?
我用盡:
SET d_UserType := CALL db.get_usertype((SELECT ID FROM User WHERE Email = in_Email));
SET d_UserType := EXEC db.get_usertype((SELECT ID FROM User WHERE Email = in_Email));
SET d_UserType := EXECUTE db.get_usertype((SELECT ID FROM User WHERE Email = in_Email));
沒有運氣..
THX的所有幫助!