MySQL存储过程
创建存储过程
DELIMITER $$ create procedure T_PROC( IN ExeType VARCHAR(64), IN in_a VARCHAR(64), IN in_b VARCHAR(64), OUT `msg` VARCHAR(64) ) BEGIN IF(ExeType='Insert') THEN INSERT into test1(a,b) VALUES(in_a,in_b); SET msg='插入成功'; ELSEIF(ExeType='Update') THEN UPDATE test1 SET b=in_b WHERE a=in_a; SET msg='修改成功'; ELSEIF(ExeType='Delete') THEN DELETE FROM test1 WHERE a=in_a; SET msg='删除成功'; ELSEIF(ExeType='Query') THEN SELECT * FROM test1 WHERE a=in_a; END IF; END $$
执行存储过程
delimiter; CALL T_PROC('Query','33','55',@msg); select @msg; SELECT * from test1