使用 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 // Query OK, 0 rows affected (0.21 sec) 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) Query OK, 0 rows affected, 1 warning (0.04 sec)
广告