CREATE PROCEDURE `spAddTimeTable` ( IN `P_BatchId` INTEGER , IN `P_TimeTableXml` LONGTEXT , IN `P_TimeTableId` INTEGER , IN `P_Day` VARCHARACTER (?) , IN `P_FromTime` TIME , IN `P_ToTime` TIME , IN `P_FromDate` DATE , IN `P_IsSession` TINYINT , IN `P_Title` LONGTEXT , IN `P_AnouncementMessage` LONGTEXT , IN `P_Subject` VARCHARACTER (?) ) BEGIN DECLARE `Count` INTEGER DEFAULT ? ; DECLARE `i` INTEGER DEFAULT ? ; DECLARE `DayCount` INTEGER DEFAULT ? ; IF ( `P_IsSession` = ? ) THEN SET `Count` = `ExtractValue` ( `P_TimeTableXml` , ? ) ; WHILE `i` <= `Count` DO IF ( `ExtractValue` ( `P_TimeTableXml` , `CONCAT` ( ? , `i` , ? ) ) = ? ) THEN INSERT INTO `vida_lms` . `ttimetable` ( `Day` , `FromTime` , `ToTime` , `BatchId` , `Subject` , `IsSession` ) VALUES ( `ExtractValue` ( `P_TimeTableXml` , `CONCAT` ( ? , `i` , ? ) ) , `ExtractValue` ( `P_TimeTableXml` , `CONCAT` ( ? , `i` , ? ) ) , `ExtractValue` ( `P_TimeTableXml` , `CONCAT` ( ? , `i` , ? ) ) , `P_BatchId` , `ExtractValue` ( `P_TimeTableXml` , `CONCAT` ( ? , `i` , ? ) ) , ? ) ; SELECT `TeacherId` AS `result` FROM `tbatch` WHERE `Id` = `P_BatchId` ; ELSEIF ( `ExtractValue` ( `P_TimeTableXml` , `CONCAT` ( 