1.表结构:
2. 存储过程中:
代码如下:
BEGIN
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
GET DIAGNOSTICS CONDITION 1 @p1=RETURNED_SQLSTATE,@p2= MESSAGE_TEXT;
SELECT @p1,@p2;
END;
start transaction;
#会出错的语句
INSERT INTO test(nn,x) VALUES (3,'t');
#INSERT INTO test (nn,x) VALUES(2,3);
COMMIT;
END