CREATE PROCEDURE `spDeleteComment` ( IN `P_UserId` INTEGER , IN `P_CommentId` INTEGER ) BEGIN IF EXISTS ( SELECT ? FROM `tstudymaterialcomment` WHERE `Id` = `P_CommentId` AND `UserId` = `P_UserId` ) THEN START TRANSACTION ; DELETE FROM `tstudymaterialcomment` WHERE `Id` = `P_CommentId` OR `ReferenceCommentId` = `P_CommentId` ; SELECT ? ; COMMIT ; ELSE SELECT ? ; END IF ; END 