CodePudding user response:
Delimiter//
CREATE PROCEDURE test. Delete11 (IN xuehao VARCHAR (255))
The BEGIN
DECLARE the EXCEPTION INT the DEFAULT 0;
DECLARE the EXIT HANDLER FOR SQLEXCEPTION SET EXCEPTION=1;
START the TRANSACTION;
The DELETE FROM stu WHERE StuID=xuehao;
The DELETE FROM scores the WHERE StuID=xuehao;
IF the EXCEPTION=1 THEN
The ROLLBACK.
The ELSE
COMMIT;
END IF;
END
//