CREATE PROCEDURE `spCreateNoticeBoard` ( IN `P_BatchId` INTEGER , IN `P_Remark` VARCHARACTER (?) ) BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN SELECT ? ; END ; IF EXISTS ( SELECT ? FROM `tbatch` WHERE `Id` = `P_BatchId` ) THEN START TRANSACTION ; INSERT INTO `tnoticeboard` ( `BatchId` , `Remark` , `CreatedDateTime` , `UpdatedDateTime` ) VALUES ( `P_BatchId` , `P_Remark` , NOW ( ) , NOW ( ) ) ; SELECT `CONCAT` ( `TeacherId` , ? , `LAST_INSERT_ID` ( ) ) FROM `tbatch` WHERE `Id` = `P_BatchId` ; COMMIT ; ELSE SELECT ? ; END IF ; END 