MySQL 存储过程传参之in, out, inout 参数用法
DELIMITER $$ CREATE PROCEDURE p1(IN num INT) BEGIN DECLARE i INT DEFAULT 0; DECLARE total INT DEFAULT 0; WHILE i<=num DO SET total := i + total; SET i := i+1; END WHILE; SELECT total; END$$
CREATE PROCEDURE p2(OUT num INT) BEGIN SELECT num AS num_1; IF (num IS NOT NULL) THEN SET num = num + 1; SELECT num AS num_2; ELSE SELECT 1 INTO num; END IF; SELECT num AS num_3; END$$ SET @num = 10$$ CALL p2(@num)$$ SELECT @num AS num_out$$
CREATE PROCEDURE p3(INOUT age INT) BEGIN SET age := age + 20; END$$ set @currage =18$$ call p3(@currage)$$ select @currage$$
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。