CREATE PROCEDURE `spAddEtest` ( IN `P_Id` INTEGER , IN `P_MainTestTypeId` INTEGER , IN `P_SubTestTypeId` INTEGER , IN `P_CorrectAnswerMarks` DECIMAL (...) , IN `P_PenaltyMarks` DECIMAL (...) , IN `P_IsSubmitted` BIT , IN `P_Topic` LONGTEXT , IN `P_Description` LONGTEXT , IN `P_TestDuration` INTEGER , IN `P_StartDate` DATE , IN `P_StartTime` TIME , IN `P_ExpiryDate` DATE , IN `P_ExpiryTime` TIME , IN `P_BatchId` INTEGER , IN `P_SubCategoryId` INTEGER , IN `P_CreatedUserId` INTEGER , IN `P_IsEdit` BIT , IN `P_IsMultiple` TINYINT ) BEGIN DECLARE `D_MaxMarks` DECIMAL (...) DEFAULT ? ; IF ( `P_Id` = ? ) THEN START TRANSACTION ; INSERT INTO `vida_lms` . `tetest` ( `MainTestTypeId` , `SubTestTypeId` , `CorrectAnswerMarks` , `PenaltyMarks` , `BatchId` , `Description` , `IsSubmitted` , `SubCategoryId` , `CreatedUserId` , `CreatedDateTime` , `IsMultiple` ) VALUES ( `P_MainTestTypeId` , `P_SubTestTypeId` , `P_CorrectAnswerMarks` , `P_PenaltyMarks` , `P_BatchId` , `P_Description` , `P_IsSubmitted` , `P_SubCategoryId` , `P_CreatedUserId` , NOW ( ) , `P_IsMultiple` ) ; SELECT `LAST_INSERT_ID` ( ) ; COMMIT ; ELSEIF ( `P_Id` > ? AND `P_IsSubmitted` = ? AND `P_IsEdit` = ? ) THEN SELECT SUM 