以下示例将演示带有INOUT 参数的MySQL存储过程-
mysql> DELIMITER // ; mysql> Create PROCEDURE counter(INOUT count INT, IN increment INT) -> BEGIN -> SET count = count + increment; -> END //
在这里,“ count”是INOUT参数,可以存储和返回值,而“ increment”是IN参数,可以接受用户的值。
mysql> DELIMITER ; mysql> SET @counter = 0; mysql> CALL counter(@Counter, 1); mysql> Select @Counter; +----------+ | @Counter | +----------+ | 1 | +----------+ 1 row in set (0.00 sec) mysql> CALL counter(@Counter, 5); mysql> Select @Counter; +----------+ | @Counter | +----------+ | 6 | +----------+ 1 row in set (0.00 sec)