时间:2021-07-01 10:21:17 帮助过:21人阅读
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$$