删除一个类别,并且同时把该类别下的所有文章都删除,用事务这样写对吗???
删除一个类别,并且同时把该类别下的所有文章都删除,用事务这样写对吗???
CREATE PROCEDURE DeleteClass
@ClassId int
AS
BEGIN TRANSACTION
DELETE FROM class WHERE ClassId = @ClassId
IF @@Error > 0
ROLLBACK TRANSACTION
DELETE FROM article WHERE ClassId = @ClassId
IF @@Error > 0
ROLLBACK TRANSACTION
ELSE
COMMIT TRANSACTION
------解决方案--------------------我偶像~~