CREATE PROCEDURE `spAlertGetOnlineLectureData` ( IN `P_LectureId` INTEGER , IN `P_Template` VARCHARACTER (?) , IN `P_TeacherId` INTEGER , IN `P_BatchId` INTEGER , IN `P_MailSubject` VARCHARACTER (?) , IN `P_RoleTypeId` INTEGER ) BEGIN IF ( `P_RoleTypeId` = ? ) THEN SELECT `OL` . `Id` , `B` . `TeacherId` , `B` . `Id` AS `BatchId` , `B` . `Title` AS `BatchName` , `U` . `MobileNo` , `IFNULL` ( `S` . `EmailId` , ? ) AS `EmailId` , REPLACE ( REPLACE ( `P_Template` , ? , `B` . `Title` ) , ? , `U` . `Name` ) AS `MsgText` , `P_MailSubject` AS SUBJECT , `P_RoleTypeId` AS `ReceiverRoleTypeId` , `S` . `Id` AS `ReceiverSourceId` , `T` . `UserId` AS `UserId` , `S` . `UserId` AS `ReceiverUserId` , `T` . `InstituteId` AS `InstituteId` FROM `tonlinelecture` `OL` LEFT JOIN `tteacher` `T` ON `OL` . `TeacherId` = `T` . `Id` LEFT JOIN `tbatch` `B` ON `B` . `TeacherId` = `T` . `id` LEFT JOIN `tassignbatch` `BA` ON `B` . `Id` = `BA` . `BatchId` AND `BA` . `StatusId` = ? LEFT JOIN `tstudent` `S` ON `BA` . `StudentId` = `S` . `Id` LEFT JOIN `tuser` `U` ON `T` . `UserId` = `U` . `Id` WHERE `OL` . `Id` = 