DROP PROCEDURE IF EXISTS addtest;
DELIMITER //
CREATE PROCEDURE addtest(IN name VARCHAR(255),IN job VARCHAR(255),IN add_time CHAR(10),OUT back int)
BEGIN
DECLARE error int DEFAULT 0;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET error = 1;
START TRANSACTION;
insert into t_test (`name`,`job`,`add_time`) VALUES (name,job,add_time);
IF (error = 1) THEN
       ROLLBACK;
       SET back = 0;
ELSE
       COMMIT;
      SET back = 1;
      END IF;
END //
DELIMITER ;

CALL addtest('lzc','php','15286962317',@back);
select @back;

存储过程:https://blog.51cto.com/lzcit/5162070