使用INT和VARCHAR值调用的MySQL存储过程
要调用存储过程,可以使用CALL命令。以下是语法-
CALL yourStoredProcedureName(parameter if any);
让我们首先创建一个示例过程。以下是创建存储过程的查询。在这里,我们设置了两个值,一个是INT,另一个是VARCHAR-
mysql> DELIMITER // mysql> CREATE PROCEDURE CALL_PROC(Id int,Name varchar(40)) BEGIN SELECT CONCAT('You have entered the Id which is=',Id); SELECT CONCAT('You have entered the Name which is=',Name); END // mysql> DELIMITER ;
以下是在MySQL中调用存储过程的查询-
mysql> CALL CALL_PROC(1001,'Chris');
这将产生以下输出-
+------------------------------------------------+ | CONCAT('You have entered the Id which is=',Id) | +------------------------------------------------+ | You have entered the Id which is=1001 | +------------------------------------------------+ 1 row in set (0.00 sec) +----------------------------------------------------+ | CONCAT('You have entered the Name which is=',Name) | +----------------------------------------------------+ | You have entered the Name which is=Chris | +----------------------------------------------------+ 1 row in set (0.02 sec)