CREATE PROCEDURE `spAlertGetAssignBatch` ( IN `P_Template` VARCHARACTER (?) , IN `P_MailSubject` VARCHARACTER (?) , IN `P_BatchId` INTEGER , IN `P_TeacherId` INTEGER , IN `P_StudentId` INTEGER , IN `P_IsActive` BIT , IN `P_RoleTypeId` INTEGER ) BEGIN IF ( `P_RoleTypeId` = ? ) THEN IF ( `P_IsActive` = TRUE ) THEN SELECT `B` . `Id` AS `BatchId` , `B` . `Title` AS `BatchName` , `B` . `TeacherId` , `AB` . `StudentId` , `AB` . `StatusId` , `SM` . `Title` AS `StatusTitle` , `T` . `UserId` AS `UserId` , `U` . `MobileNo` , `IFNULL` ( `S` . `EmailId` , ? ) AS `EmailId` , REPLACE ( REPLACE ( REPLACE ( `P_Template` , ? , `B` . `Title` ) , ? , `U1` . `Name` ) , ? , `U` . `Name` ) AS `MsgText` , `P_MailSubject` AS SUBJECT , ? AS `ReceiverRoleTypeId` , `S` . `Id` AS `ReceiverSourceId` , `S` . `UserId` AS `ReceiverUserId` , `T` . `InstituteId` AS `InstituteId` FROM `tbatch` `B` LEFT JOIN `tassignbatch` `AB` ON `AB` . `BatchId` = `B` . `Id` LEFT JOIN `tstatusmaster` `SM` ON `SM` . `Id` = `AB` . `StatusId` AND `StatusTypeId` = ? LEFT JOIN `tstudent` `S` ON `AB` . `StudentId` = `S` . `Id` LEFT JOIN 