DROP PROCEDURE IF EXISTS addtest;
DELIMITER //
代码语言:javascript复制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;
存储过程:http://blog.sina.com.cn/s/blog_8ff955df0102xc8w.html