创建带有IN类型的存储过程
CREATE PROCEDURE removeUserById(IN id INT UNSIGNED)
BEGIN
DELETE FROM users WHERE id=id;
END
创建带有IN、out类型的存储过程
CREATE PROCEDURE removeUserAndReturnUserNums(IN UNSIGNED,OUTuserNums INT UNSIGNED)
DEGIN
DELETE FROM users FROM users WHERE id=p_id;
SELECT count(id) FROM users INTO userNums;
END
创建带有多个out类型的存储过程
CREATE PROCEDURE removeUserByAgeAndReturnInfos(IN p_age SMALLINTUNSIGNED,OUT deleteUser SMALLINT UNSIGNED,OUT userCounts SMALLINTUNSIGNED)
BEGIN
DELETE FROM user WHERE age = p_age;
SELECT ROW_COUNT() INTO deleteUsers;
SELECT COUNT(id) INTO userCounts;
END